|
@@ -105,40 +105,43 @@
|
|
|
when: "current_python_version.rc == 0 and not current_python_version.stdout.startswith(python_version | string)"
|
|
|
notify:
|
|
|
- Restart WSGI services
|
|
|
|
|
|
- name: Create directory for storing the Python virtual environment
|
|
|
file:
|
|
|
path: "{{ home }}/virtualenv"
|
|
|
state: directory
|
|
|
owner: "{{ admin }}"
|
|
|
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
|
|
|
become_user: "{{ admin }}"
|
|
|
tags:
|
|
|
# [ANSIBLE0012] Commands should not change things if nothing needs doing
|
|
|
# This task will not fire if the virtual environment has already bene
|
|
|
# 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 }}"
|
|
|
|
|
|
# Workaround for:
|
|
|
#
|
|
|
# - https://github.com/pypa/pip/issues/4022
|
|
|
# - https://bugs.launchpad.net/ubuntu/+source/python-pip/+bug/1635463
|
|
|
# - https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=871790
|
|
|
- name: Remove the pkg-resources package from virtual environment (see comments above for details)
|
|
|
pip:
|
|
|
name: pkg-resources
|
|
@@ -165,24 +168,38 @@
|
|
|
|
|
|
- name: Install WSGI server
|
|
|
become: true
|
|
|
become_user: "{{ admin }}"
|
|
|
pip:
|
|
|
name: "{{ item.package }}"
|
|
|
version: "{{ item.version }}"
|
|
|
state: present
|
|
|
virtualenv: "{{ home }}/virtualenv"
|
|
|
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"
|
|
|
register: install_wsgi_server
|
|
|
notify:
|
|
|
- Restart WSGI services
|
|
|
|
|
|
- include: requirements.yml
|
|
|
when: "wsgi_requirements"
|
|
|
|
|
|
- name: Install additional packages in Python virtual environment
|
|
|
become: true
|