|
@@ -369,11 +369,24 @@
|
|
|
changed_when: false
|
|
|
register: virtualenv_python_version
|
|
|
|
|
|
- name: Remove virtual environment if Python version does not match
|
|
|
- name: Retrieve virtual environment prompt
|
|
|
command:
|
|
|
argv:
|
|
|
- "bash"
|
|
|
- "-c"
|
|
|
- "source '/var/lib/pipreqcheck/virtualenv/bin/activate'; printenv PS1"
|
|
|
failed_when: false
|
|
|
changed_when: false
|
|
|
register: current_virtualenv_prompt
|
|
|
|
|
|
- name: Remove virtual environment in case of mismatches
|
|
|
file:
|
|
|
path: "/var/lib/pipreqcheck/virtualenv"
|
|
|
state: absent
|
|
|
when: "virtualenv_python_version.rc != 0 or virtualenv_python_version.stdout.strip() != python_interpreter_version.stdout.strip()"
|
|
|
when: |
|
|
|
virtualenv_python_version.rc != 0 or
|
|
|
virtualenv_python_version.stdout.strip() != python_interpreter_version.stdout.strip() or
|
|
|
current_virtualenv_prompt.stdout != "(pipreqcheck) "
|
|
|
|
|
|
- name: Create directory for Python virtual environment used for installing/running pip-tools
|
|
|
file:
|
|
@@ -387,7 +400,7 @@
|
|
|
- "/var/lib/pipreqcheck/virtualenv"
|
|
|
|
|
|
- name: Create Python virtual environment used for installing/running pip-tools
|
|
|
command: "/usr/bin/virtualenv --python '{{ item.python_path }}' --prompt '({{ item.name }})' '{{ item.virtualenv_path }}'"
|
|
|
command: "/usr/bin/virtualenv --python '{{ item.python_path }}' --prompt '{{ item.virtualenv_prompt }}' '{{ item.virtualenv_path }}'"
|
|
|
args:
|
|
|
creates: "{{ item.creates }}"
|
|
|
become: true
|
|
@@ -395,6 +408,7 @@
|
|
|
with_items:
|
|
|
- name: pipreqcheck
|
|
|
virtualenv_path: "/var/lib/pipreqcheck/virtualenv"
|
|
|
virtualenv_prompt: "{% if ansible_distribution_release == 'bullseye' %}(pipreqcheck) {% else %}pipreqcheck{% endif %}"
|
|
|
python_path: "/usr/bin/python3"
|
|
|
creates: "/var/lib/pipreqcheck/virtualenv/bin/python3"
|
|
|
|