summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-06-19 14:10:23 +0000
committerGerrit Code Review <review@openstack.org>2018-06-19 14:10:23 +0000
commitea66e8132bfbec2e330f8e0b05f954a700e2e2c9 (patch)
treee9f87eea76044147490293fef0f8411ba6f9d59d
parentaf7be5275e59f38b302d69aa4aaf068df33d1a9a (diff)
parent8857b3054c11b6b0ed46d889eefbdcbad7e71463 (diff)
Merge "Add support for installing from source"HEADmaster
-rw-r--r--defaults/main.yml21
-rw-r--r--tasks/install/pip.yml61
-rw-r--r--tasks/main.yml34
-rw-r--r--templates/apache_mod_wsgi.conf.j26
4 files changed, 83 insertions, 39 deletions
diff --git a/defaults/main.yml b/defaults/main.yml
index e1491dd..f4ef6c5 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -18,10 +18,23 @@
18 18
19ara: 19ara:
20 params: 20 params:
21 # If ARA should be installed inside a virtualenv 21 install:
22 virtualenv: true 22 # The method used to install ARA ('pip' or 'distribution')
23 # Location where the virtualenv should be installed 23 method: pip
24 virtualenv_path: /opt/ara-venv 24 pip:
25 # If ARA should be installed inside a virtualenv
26 virtualenv: true
27 # Location where the virtualenv should be installed
28 virtualenv_path: /opt/ara-venv
29 # Method to install ARA with pip ('pypi' or 'source')
30 method: pypi
31 # When installing from source, location of the repository
32 # When installing from a source on the filesystem, only specify the path to the repository
33 source: git+https://git.openstack.org/openstack/ara
34 # When installing from pypi, version to install (ex: '0.15.0')
35 # When installing from source, ref to the commit, tag or branch to install
36 # Defaults to the latest version on PyPi or the master branch when installing from source
37 version:
25 config: 38 config:
26 database: "sqlite:////var/lib/ara/ansible.sqlite" 39 database: "sqlite:////var/lib/ara/ansible.sqlite"
27 # Host to listen on for embedded server, apache or nginx 40 # Host to listen on for embedded server, apache or nginx
diff --git a/tasks/install/pip.yml b/tasks/install/pip.yml
new file mode 100644
index 0000000..baa3cb5
--- /dev/null
+++ b/tasks/install/pip.yml
@@ -0,0 +1,61 @@
1---
2# Copyright (c) 2018 Red Hat, Inc.
3#
4# This file is part of ARA Records Ansible.
5#
6# ARA is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# ARA is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with ARA. If not, see <http://www.gnu.org/licenses/>.
18
19- name: Install required dependencies
20 become: true
21 package:
22 name: "{{ required_packages }}"
23 state: "present"
24
25# Debian/Ubuntu has a package for python-pip, RHEL and CentOS do not.
26# TODO: Fedora actually has a package for python-pip.
27- name: Install pip for Red Hat distributions
28 become: true
29 easy_install:
30 name: pip
31 state: present
32
33# Need to make sure setuptools is up to date
34- name: Initialize virtualenv with up-to-date setuptools
35 become: true
36 pip:
37 name: setuptools
38 state: latest
39 virtualenv: "{{ ara.params.install.pip.virtualenv_path }}"
40 when: ara.params.install.pip.virtualenv | bool
41
42- name: Install ARA with pip
43 become: true
44 vars:
45 # Manage that the 'version' argument doesn't work when installing from source
46 pkg_name: |
47 {%- if ara.params.install.pip.method == 'source' -%}
48 {{- ara.params.install.pip.source }}@{{ ara.params.install.pip.version | default('master') -}}
49 {%- else -%}
50 ara
51 {%- endif -%}
52 pip:
53 name: "{{ pkg_name }}"
54 version: "{{ ara.params.install.pip.version | default(omit, True) }}"
55 state: present
56 virtualenv: "{{ ara.params.install.pip.virtualenv | bool | ternary(ara.params.install.pip.virtualenv_path, omit) }}"
57
58- name: Suffix the virtualenv bin directory to PATH
59 set_fact:
60 path_with_virtualenv: "{{ ara.params.install.pip.virtualenv_path }}/bin:{{ ansible_env.PATH }}"
61 when: ara.params.install.pip.virtualenv | bool
diff --git a/tasks/main.yml b/tasks/main.yml
index e91ee2a..fb4faa5 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -29,38 +29,8 @@
29 - ara_override is defined 29 - ara_override is defined
30 - ara_override is mapping 30 - ara_override is mapping
31 31
32- name: Install required dependencies 32- name: Include ARA installation
33 become: true 33 include_tasks: "install/{{ ara.params.install.method }}.yml"
34 package:
35 name: "{{ required_packages }}"
36 state: "present"
37
38- name: Install pip
39 become: true
40 easy_install:
41 name: pip
42 state: present
43
44# Need to make sure setuptools is up to date
45- name: Initialize virtualenv with up-to-date setuptools
46 become: true
47 pip:
48 name: setuptools
49 state: latest
50 virtualenv: "{{ ara.params.virtualenv_path }}"
51 when: ara.params.virtualenv | bool
52
53- name: Install ARA with pip
54 become: true
55 pip:
56 name: ara
57 state: present
58 virtualenv: "{{ ara.params.virtualenv | bool | ternary(ara.params.virtualenv_path, omit) }}"
59
60- name: Suffix the virtualenv bin directory to PATH
61 set_fact:
62 path_with_virtualenv: "{{ ara.params.virtualenv_path }}/bin:{{ ansible_env.PATH }}"
63 when: ara.params.virtualenv | bool
64 34
65- name: Create user for ARA 35- name: Create user for ARA
66 become: true 36 become: true
diff --git a/templates/apache_mod_wsgi.conf.j2 b/templates/apache_mod_wsgi.conf.j2
index 5083f52..ac561b7 100644
--- a/templates/apache_mod_wsgi.conf.j2
+++ b/templates/apache_mod_wsgi.conf.j2
@@ -6,11 +6,11 @@
6 CustomLog {{ apache_log_path }}/ara-access.log combined 6 CustomLog {{ apache_log_path }}/ara-access.log combined
7 7
8 SetEnv ANSIBLE_CONFIG /etc/ara/ara.cfg 8 SetEnv ANSIBLE_CONFIG /etc/ara/ara.cfg
9 {% if ara.params.virtualenv -%} 9 {% if ara.params.install.pip.virtualenv -%}
10 SetEnv ARA_WSGI_USE_VIRTUALENV 1 10 SetEnv ARA_WSGI_USE_VIRTUALENV 1
11 SetEnv ARA_WSGI_VIRTUALENV_PATH {{ ara.params.virtualenv_path }} 11 SetEnv ARA_WSGI_VIRTUALENV_PATH {{ ara.params.install.pip.virtualenv_path }}
12 12
13 WSGIDaemonProcess ara user=ara group=ara processes=1 threads=4 python-home={{ ara.params.virtualenv_path }} 13 WSGIDaemonProcess ara user=ara group=ara processes=1 threads=4 python-home={{ ara.params.install.pip.virtualenv_path }}
14 {% else -%} 14 {% else -%}
15 WSGIDaemonProcess ara user=ara group=ara processes=1 threads=4 15 WSGIDaemonProcess ara user=ara group=ara processes=1 threads=4
16 {% endif -%} 16 {% endif -%}