From 0bf325d2fed241a3ff7e6352efae9e4972dd78e2 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Fri, 2 Oct 2020 10:22:37 +0200 Subject: [PATCH] testdays: Setup the DB for testsdays in the playbook directly Signed-off-by: Pierre-Yves Chibon --- playbooks/openshift-apps/testdays.yml | 37 +++++++++++++++++++ .../testdays/templates/deploymentconfig.yml | 4 +- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/playbooks/openshift-apps/testdays.yml b/playbooks/openshift-apps/testdays.yml index 25b48beb33..71a2504490 100644 --- a/playbooks/openshift-apps/testdays.yml +++ b/playbooks/openshift-apps/testdays.yml @@ -1,3 +1,40 @@ +- name: prepare setting up the database + hosts: db01.stg.iad2.fedoraproject.org #:db01.iad2.fedoraproject.org + gather_facts: no + user: root + + tasks: + - name: install psycopg2 for the postgresql ansible modules + package: name=python3-psycopg2 state=present + tags: + - packages + +- name: setup the database + hosts: db01.stg.iad2.fedoraproject.org #:db01.iad2.fedoraproject.org + gather_facts: no + become: yes + become_user: postgres + vars_files: + - /srv/web/infra/ansible/vars/global.yml + - "/srv/private/ansible/vars.yml" + - "/srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml" + + tasks: + - name: Create the database user + postgresql_user: + name: "{{ testdays_db_user }}" + password: "{{ testdays_db_pass }}" + - name: Create the database itself + postgresql_db: + name: "{{ testdays_db_name }}" + owner: "{{ testdays_db_user }}" + encoding: UTF-8 + - name: Test the database creation + postgresql_db: + name: "{{ testdays_db_name }}" + owner: "{{ testdays_db_user }}" + encoding: UTF-8 + - name: make the app be real hosts: os_masters_stg[0] #:os_masters[0]: user: root diff --git a/roles/openshift-apps/testdays/templates/deploymentconfig.yml b/roles/openshift-apps/testdays/templates/deploymentconfig.yml index 0892871ca1..4231c5ece4 100644 --- a/roles/openshift-apps/testdays/templates/deploymentconfig.yml +++ b/roles/openshift-apps/testdays/templates/deploymentconfig.yml @@ -34,9 +34,9 @@ spec: - name: POSTGRESQL_DATABASE value: "{{ }}" - name: POSTGRESQL_SERVICE_HOST - value: "{{ }}" + value: "db01{{ env_suffix }}.iad2.fedoraproject.org" - name: POSTGRESQL_SERVICE_PORT - value: "{{ }}" + value: "5432" - name: SECRET_KEY value: "{{ }}" - name: RESULTSDB_URL