summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Moreau Simard <dmsimard@redhat.com>2018-10-17 00:11:16 -0400
committerDavid Moreau Simard <dmsimard@redhat.com>2018-10-17 00:11:16 -0400
commit5eaafe1030956eb93f2d2519657dc72a17645fab (patch)
treee501c611c3be6901c8540b557e5067ef1fab8fcd
parentc51366f72203314a2e970368d1181975918a7ce6 (diff)
Automatically install pymysql or psycopg2 if necessaryHEADmaster
If a user is supplying a pymysql or psycopg2 connection string, the necessary driver needs to be installed before it can be used. Change-Id: I4655c9a39fea6a43f7e579f099d61836577202f0
Notes
Notes (review): Code-Review+2: David Moreau Simard <dmsimard@redhat.com> Workflow+1: David Moreau Simard <dmsimard@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 23 Oct 2018 19:17:59 +0000 Reviewed-on: https://review.openstack.org/611231 Project: openstack/ansible-role-ara Branch: refs/heads/master
-rw-r--r--defaults/main.yml1
-rw-r--r--tasks/install/pip.yml16
2 files changed, 17 insertions, 0 deletions
diff --git a/defaults/main.yml b/defaults/main.yml
index e3c46e0..640da16 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -35,6 +35,7 @@ ara:
35 # Defaults to the latest version on PyPi or the master branch when installing from source 35 # Defaults to the latest version on PyPi or the master branch when installing from source
36 version: 36 version:
37 config: 37 config:
38 # If pymysql or psycopg2 are found in the connection string, the role will install the necessary driver
38 database: "sqlite:////var/lib/ara/ansible.sqlite" 39 database: "sqlite:////var/lib/ara/ansible.sqlite"
39 # Host to listen on for embedded server, apache or nginx 40 # Host to listen on for embedded server, apache or nginx
40 host: 127.0.0.1 41 host: 127.0.0.1
diff --git a/tasks/install/pip.yml b/tasks/install/pip.yml
index 7cb4c38..90bc987 100644
--- a/tasks/install/pip.yml
+++ b/tasks/install/pip.yml
@@ -55,6 +55,22 @@
55 state: present 55 state: present
56 virtualenv: "{{ ara.install.pip.virtualenv | bool | ternary(ara.install.pip.virtualenv_path, omit) }}" 56 virtualenv: "{{ ara.install.pip.virtualenv | bool | ternary(ara.install.pip.virtualenv_path, omit) }}"
57 57
58- name: Install pymysql with pip
59 become: true
60 pip:
61 name: pymysql
62 state: present
63 virtualenv: "{{ ara.install.pip.virtualenv | bool | ternary(ara.install.pip.virtualenv_path, omit) }}"
64 when: '"pymysql" in ara.config.database'
65
66- name: Install psycopg2 with pip
67 become: true
68 pip:
69 name: psycopg2
70 state: present
71 virtualenv: "{{ ara.install.pip.virtualenv | bool | ternary(ara.install.pip.virtualenv_path, omit) }}"
72 when: '"psycopg2" in ara.config.database'
73
58- name: Suffix the virtualenv bin directory to PATH 74- name: Suffix the virtualenv bin directory to PATH
59 set_fact: 75 set_fact:
60 path_with_virtualenv: "{{ ara.install.pip.virtualenv_path }}/bin:{{ ansible_env.PATH }}" 76 path_with_virtualenv: "{{ ara.install.pip.virtualenv_path }}/bin:{{ ansible_env.PATH }}"