From fdef430f4e466381d7abf0a0bea6a8cf69a9bbd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bompard?= Date: Wed, 24 Jan 2018 16:03:32 +0000 Subject: [PATCH] Hubs: don't rely on become being set globally --- roles/hubs/tasks/db-postgresql.yml | 3 +++ roles/hubs/tasks/db-sqlite.yml | 1 + roles/hubs/tasks/main.yml | 9 +++++++++ 3 files changed, 13 insertions(+) diff --git a/roles/hubs/tasks/db-postgresql.yml b/roles/hubs/tasks/db-postgresql.yml index 2a9eec915c..017674c5f1 100644 --- a/roles/hubs/tasks/db-postgresql.yml +++ b/roles/hubs/tasks/db-postgresql.yml @@ -28,6 +28,7 @@ name: hubs password: "{{ hubs_db_password }}" role_attr_flags: NOSUPERUSER,NOCREATEROLE,NOCREATEDB + become: true become_user: postgres - name: Create the database @@ -35,6 +36,7 @@ name: hubs owner: hubs register: db_creation + become: true become_user: postgres - name: Ease local access to the database @@ -51,6 +53,7 @@ chdir: "{{ hubs_code_dir }}" environment: HUBS_CONFIG: "{{ hubs_conf_dir }}/hubs_config.py" + become: true become_user: "{{ main_user }}" when: db_creation|succeeded and db_creation|changed diff --git a/roles/hubs/tasks/db-sqlite.yml b/roles/hubs/tasks/db-sqlite.yml index 624c726019..9d15e816d5 100644 --- a/roles/hubs/tasks/db-sqlite.yml +++ b/roles/hubs/tasks/db-sqlite.yml @@ -5,4 +5,5 @@ chdir: "{{ hubs_code_dir }}" environment: HUBS_CONFIG: "{{ hubs_conf_dir }}/hubs_config.py" + become: true become_user: "{{ main_user }}" diff --git a/roles/hubs/tasks/main.yml b/roles/hubs/tasks/main.yml index db877d2c8d..534c13fa79 100644 --- a/roles/hubs/tasks/main.yml +++ b/roles/hubs/tasks/main.yml @@ -58,6 +58,7 @@ # Set up the Python development environment - name: Install Fedora Hubs requirements.txt into hubs virtualenv + become: true become_user: "{{ main_user }}" pip: requirements: "{{ hubs_code_dir }}/requirements.txt" @@ -66,6 +67,7 @@ virtualenv_command: virtualenv-3 - name: Install Fedora Hubs test-requirements.txt into hubs virtualenv + become: true become_user: "{{ main_user }}" pip: requirements: "{{ hubs_code_dir }}/test-requirements.txt" @@ -74,6 +76,7 @@ virtualenv_command: virtualenv-3 - name: Install other packages into hubs virtualenv + become: true become_user: "{{ main_user }}" pip: name: "{{ item }}" @@ -84,12 +87,14 @@ - bleach - name: Install Fedora Hubs into the virtualenv + become: true become_user: "{{ main_user }}" command: "{{ hubs_venv_dir }}/bin/pip install -e {{ hubs_code_dir }}" args: creates: "{{ hubs_venv_dir }}/lib/python3.6/site-packages/fedora-hubs.egg-link" - name: Set bin file context in the virtualenv + become: true become_user: "{{ main_user }}" file: path: "{{ hubs_venv_dir }}/bin" @@ -104,6 +109,7 @@ with_first_found: - hubs_config.{{ ansible_hostname }} - hubs_config + become: true become_user: "{{ main_user }}" notify: "hubs configuration change" @@ -121,6 +127,7 @@ oidc-register --output-file {{ hubs_conf_dir }}/client_secrets.json https://iddev.fedorainfracloud.org/ {{ hubs_url }} + become: true become_user: "{{ main_user }}" args: creates: "{{ hubs_conf_dir }}/client_secrets.json" @@ -139,6 +146,7 @@ # Set up JavaScript requirements - name: Install npm packages command: npm install + become: true become_user: "{{ main_user }}" args: creates: node_modules @@ -146,6 +154,7 @@ - name: Build JavaScript assets command: npm run build + become: true become_user: "{{ main_user }}" args: chdir: "{{ hubs_code_dir }}/hubs/static/client"