Changeset - a5d38f30094b
[Not reviewed]
0 2 0
Branko Majic (branko) - 6 years ago 2018-08-12 11:49:02
branko@majic.rs
MAR-132: Workarounds for wsgi_website Python virtual environment in Debian Stretch:

- Manually install setuptools in Python virtual environment on Debian
Stretch, otherwise the pkg-resources==0.0.0 package will mess with
pip freeze etc.
- Add back installation of futures package, even on Python 3 (since it
does not cause any harm).
- A small cleanup of how requirements are treated will be done in
separate ticket.
2 files changed with 20 insertions and 2 deletions:
0 comments (0 inline, 0 general)
roles/wsgi_website/defaults/main.yml
Show inline comments
 
@@ -23,3 +23,4 @@ admin: "admin-{{ fqdn | replace('.', '_') }}"
 
user: "web-{{ fqdn | replace('.', '_') }}"
 
home: "/var/www/{{ fqdn }}"
 
python_interpreter: "/usr/bin/python{{ python_version }}"
 
no_setuptools: "{% if ansible_distribution_release == 'jessie' %}{% elif ansible_distribution_release == 'stretch' %}--no-setuptools{% endif %}"
roles/wsgi_website/tasks/main.yml
Show inline comments
 
@@ -114,8 +114,10 @@
 
    group: "{{ user }}"
 
    mode: 02750
 

	
 
# setuptools is excluded on Stretch, because it would pull-in the
 
# pkg-resources package that then messes with pip freeze etc.
 
- name: Create Python virtual environment
 
  command: '/usr/bin/virtualenv --python "{{ python_interpreter }}" --prompt "({{ fqdn }})" "{{ home }}/virtualenv"'
 
  command: '/usr/bin/virtualenv {{ no_setuptools }} --python "{{ python_interpreter }}" --prompt "({{ fqdn }})" "{{ home }}/virtualenv"'
 
  args:
 
    creates: "{{ home }}/virtualenv/bin/{{ python_interpreter | basename }}"
 
  become: true
 
@@ -126,10 +128,11 @@
 
    #   created (thanks to 'creates' parameter).
 
    - skip_ansible_lint
 

	
 
- name: Install latest pip in virtual environment
 
- name: Install latest pip and setuptools in virtual environment
 
  pip:
 
    name:
 
      - "pip>=18.0.0,<19.0.0"
 
      - "setuptools>=40.0.0,<41.0.0"
 
    virtualenv: "{{ home }}/virtualenv"
 
  become: true
 
  become_user: "{{ admin }}"
 
@@ -174,6 +177,20 @@
 
  with_items:
 
    - package: gunicorn
 
      version: "{{ gunicorn_version }}"
 
  when: "not wsgi_requirements"
 
  register: install_wsgi_server
 
  notify:
 
    - Restart WSGI services
 

	
 
- name: Install futures Python 2 backport (for WSGI server)
 
  become: true
 
  become_user: "{{ admin }}"
 
  pip:
 
    name: "{{ item.package }}"
 
    version: "{{ item.version }}"
 
    state: present
 
    virtualenv: "{{ home }}/virtualenv"
 
  with_items:
 
    - package: futures
 
      version: "{{ futures_version }}"
 
  when: "not wsgi_requirements"
0 comments (0 inline, 0 general)