Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/python_runner/tasks/main.yml

raw
1 # Copyright (c) 2026, Alexei Znamensky <[email protected]>
2 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
3 # SPDX-License-Identifier: GPL-3.0-or-later
4
5 - name: Create virtualenv
6 ansible.builtin.command:
7 cmd: "{{ ansible_python_interpreter }} -m venv {{ remote_tmp_dir }}/venv"
8
9 - name: Update pip in virtualenv
10 ansible.builtin.pip:
11 name: pip
12 state: latest
13 virtualenv: "{{ remote_tmp_dir }}/venv"
14
15 - name: Install django in virtualenv
16 ansible.builtin.pip:
17 name: django
18 state: present
19 virtualenv: "{{ remote_tmp_dir }}/venv"
20
21 # Regression test for https://github.com/ansible-collections/community.general/issues/8884
22 # Bug: PythonRunner was setting path_prefix to a string instead of a list, corrupting PATH
23 # when venv was specified, so the venv's python could not be found.
24 # The original reporter was running `migrate`; we use `check` to avoid needing a database.
25 - name: Create Django project using venv django-admin
26 ansible.builtin.command:
27 cmd: "{{ remote_tmp_dir }}/venv/bin/django-admin startproject testproject"
28 chdir: "{{ remote_tmp_dir }}"
29
30 - name: Run django_command check on the created project (issue 8884 scenario)
31 community.general.django_command:
32 command: check
33 settings: testproject.settings
34 pythonpath: "{{ remote_tmp_dir }}/testproject"
35 venv: "{{ remote_tmp_dir }}/venv"
36 register: result_project_check
37
38 - name: Assert project check succeeded and returned a version
39 ansible.builtin.assert:
40 that:
41 - result_project_check is success
42 - result_project_check.version is defined
43 - result_project_check.version != ""