File diff 7f4f7163ae31 → 8457949f27d4
roles/common/tasks/main.yml
Show inline comments
 
@@ -336,20 +336,31 @@
 
    home: "/var/lib/pipreqcheck"
 
    state: present
 

	
 
- name: Check for presence of wrong Python versions
 
  stat:
 
    path: "{{ item.offending_binary }}"
 
  with_items:
 
    - offending_binary: "/var/lib/pipreqcheck/virtualenv/bin/python2"
 
      virtualenv_directory: "/var/lib/pipreqcheck/virtualenv"
 
  register: "pipreqcheck_wrong_python_version_check"
 
- name: Retrieve system Python interpreter version
 
  command:
 
    argv:
 
      - "/usr/bin/python3"
 
      - "-c"
 
      - "import sys; print(sys.version.split(' ')[0])"
 
  changed_when: false
 
  register: python_interpreter_version
 

	
 
- name: Retrieve virtual environment Python interpreter version (if initialised)
 
  command:
 
    argv:
 
      - "/var/lib/pipreqcheck/virtualenv/bin/python"
 
      - "-c"
 
      - "import sys; print(sys.version.split(' ')[0])"
 
  # Virtual environment perhaps does not exist.
 
  failed_when: false
 
  changed_when: false
 
  register: virtualenv_python_version
 

	
 
- name: Drop Python virtual environment if wrong Python version has been detected within
 
- name: Remove virtual environment if Python version does not match
 
  file:
 
    path: "{{ item.item.virtualenv_directory }}"
 
    path: "/var/lib/pipreqcheck/virtualenv"
 
    state: absent
 
  when: "item.stat.exists"
 
  with_items: "{{ pipreqcheck_wrong_python_version_check.results }}"
 
  when: "virtualenv_python_version.rc != 0 or virtualenv_python_version.stdout.strip() != python_interpreter_version.stdout.strip()"
 

	
 
- name: Create directory for Python virtual environment used for installing/running pip-tools
 
  file: