Default the ARA installation to a virtualenv

Installing ARA and Ansible system-wide by default is a bit invasive.

Let's default to a virtual environment instead. This means making
sure Apache's mod_wsgi deployment can use that virtualenv amongst
other things.

Depends-On: https://review.openstack.org/567280
Change-Id: I4d86e343b745e31e509dbc929d1fd2c2b10a3623
This commit is contained in:
David Moreau Simard 2018-05-08 22:26:11 -04:00
parent b21d77e489
commit b526ed4c9a
No known key found for this signature in database
GPG Key ID: 33A07694CBB71ECC
7 changed files with 43 additions and 9 deletions

View File

@ -17,6 +17,11 @@
# along with ARA. If not, see <http://www.gnu.org/licenses/>.
ara:
params:
# If ARA should be installed inside a virtualenv
virtualenv: true
# Location where the virtualenv should be installed
virtualenv_path: /opt/ara-venv
config:
database: "sqlite:////var/lib/ara/ansible.sqlite"
# Host to listen on for embedded server, apache or nginx

View File

@ -31,6 +31,8 @@
- name: Get the location of the WSGI script
command: which ara-wsgi
environment:
PATH: "{{ path_with_virtualenv | default(omit) }}"
register: wsgi_location
changed_when: false

View File

@ -18,6 +18,8 @@
- name: Get the location of ara-manage
command: which ara-manage
environment:
PATH: "{{ path_with_virtualenv | default(omit) }}"
register: ara_manage
changed_when: false

View File

@ -41,11 +41,26 @@
name: pip
state: present
# Need to make sure setuptools is up to date
- name: Initialize virtualenv with up-to-date setuptools
become: true
pip:
name: setuptools
state: latest
virtualenv: "{{ ara.params.virtualenv_path }}"
when: ara.params.virtualenv | bool
- name: Install ARA with pip
become: true
pip:
name: ara
state: present
virtualenv: "{{ ara.params.virtualenv | bool | ternary(ara.params.virtualenv_path, omit) }}"
- name: Suffix the virtualenv bin directory to PATH
set_fact:
path_with_virtualenv: "{{ ara.params.virtualenv_path }}/bin:{{ ansible_env.PATH }}"
when: ara.params.virtualenv | bool
- name: Create user for ARA
become: true
@ -93,8 +108,10 @@
- restart ara
- restart nginx
- name: Get ARA installed location
shell: python -c "import os,ara; print(os.path.dirname(ara.__file__))"
- name: Get ARA's installed location
command: python -m ara.setup.path
environment:
PATH: "{{ path_with_virtualenv | default(omit) }}"
register: ara_location
changed_when: false

View File

@ -5,17 +5,23 @@
LogLevel warn
CustomLog {{ apache_log_path }}/ara-access.log combined
SetEnv ANSIBLE_CONFIG /etc/ara/ara.cfg
{% if ara.params.virtualenv -%}
SetEnv ARA_WSGI_USE_VIRTUALENV 1
SetEnv ARA_WSGI_VIRTUALENV_PATH {{ ara.params.virtualenv_path }}
WSGIDaemonProcess ara user=ara group=ara processes=1 threads=4 python-home={{ ara.params.virtualenv_path }}
{% else -%}
WSGIDaemonProcess ara user=ara group=ara processes=1 threads=4
{% endif -%}
WSGIScriptAlias {{ ara.config.application_root }} {{ wsgi_script }}
WSGIProcessGroup ara
WSGIApplicationGroup %{GLOBAL}
<Directory "{{ wsgi_script | dirname }}">
<Files "ara-wsgi">
Allow from all
Satisfy Any
</Files>
</Directory>
WSGIDaemonProcess ara user=ara group=ara processes=1 threads=4
WSGIScriptAlias {{ ara.config.application_root }} {{ wsgi_script }}
WSGIProcessGroup ara
WSGIApplicationGroup %{GLOBAL}
SetEnv ANSIBLE_CONFIG /etc/ara/ara.cfg
</VirtualHost>

View File

@ -24,6 +24,7 @@ required_packages:
- libxslt-dev
- python-dev
- python-setuptools
- python-virtualenv
- debianutils
required_wsgi_packages:

View File

@ -25,6 +25,7 @@ required_packages:
- openssl-devel
- python-devel
- python-setuptools
- python-virtualenv
- redhat-rpm-config
- which