From 7af82ea854bd14297a3fe5faaa90f537c99a9b24 Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Sat, 27 Aug 2016 12:52:33 -0400 Subject: [PATCH] Add zuul_task_manager to expose control of tasks There might be a time were we only want run the pre task, so rather then copying the code into another modules, just allow the user to override the task list that runs. Change-Id: I97a40294ac3332bcce20ca4e3458c9988816c6c7 Signed-off-by: Paul Belanger --- defaults/main.yaml | 7 +++++++ tasks/install.yaml | 3 +++ tasks/install/git.yaml | 2 ++ tasks/install/pip.yaml | 2 ++ tasks/main.yaml | 14 ++++---------- tasks/service.yaml | 7 +++++++ 6 files changed, 25 insertions(+), 10 deletions(-) diff --git a/defaults/main.yaml b/defaults/main.yaml index 2395c80..7fe4605 100644 --- a/defaults/main.yaml +++ b/defaults/main.yaml @@ -12,6 +12,13 @@ # License for the specific language governing permissions and limitations # under the License. --- +# tasks/main.yaml +zuul_task_manager: + - pre + - install + - config + - service + # tasks/config.yaml zuul_user_name: zuul zuul_user_group: zuul diff --git a/tasks/install.yaml b/tasks/install.yaml index 0ac0c57..19e3b65 100644 --- a/tasks/install.yaml +++ b/tasks/install.yaml @@ -19,6 +19,7 @@ # NOTE(pabelanger): This needs to be here for now, since we need python-pip. - name: Ensure EPEL is enabled. + become: yes package: name: epel-release state: installed @@ -26,6 +27,7 @@ ansible_os_family == 'RedHat' - name: Ensure build dependencies are installed. + become: yes package: name: "{{ item }}" state: installed @@ -37,6 +39,7 @@ # TODO(pabelanger): Remove once https://review.openstack.org/#/c/316387/ has # been merged. - name: Install missing pip dependencies + become: yes pip: name: "{{ item }}" with_items: diff --git a/tasks/install/git.yaml b/tasks/install/git.yaml index f9620c7..af0cd15 100644 --- a/tasks/install/git.yaml +++ b/tasks/install/git.yaml @@ -13,11 +13,13 @@ # under the License. --- - name: Git clone zuul. + become: yes git: dest: "{{ zuul_git_dest }}" repo: "{{ zuul_git_uri }}" version: "{{ zuul_git_version }}" - name: Pip install zuul from local git repo. + become: yes pip: name: "file://{{ zuul_git_dest }}" diff --git a/tasks/install/pip.yaml b/tasks/install/pip.yaml index d9252a5..fdf4eea 100644 --- a/tasks/install/pip.yaml +++ b/tasks/install/pip.yaml @@ -13,11 +13,13 @@ # under the License. --- - name: Install zuul using pip. + become: yes pip: name: zuul when: zuul_pip_version is none - name: Install zuul using pip. + become: yes pip: name: zuul version: "{{ zuul_pip_version }}" diff --git a/tasks/main.yaml b/tasks/main.yaml index 429695c..cf32793 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -15,13 +15,7 @@ - name: Include OS-specific variables. include_vars: "{{ ansible_os_family }}.yaml" -- include: pre.yaml - become: yes - -- include: install.yaml - become: yes - -- include: config.yaml - -- include: service.yaml - become: yes +- include: "{{ zuul_task }}.yaml" + with_items: "{{ zuul_task_manager }}" + loop_control: + loop_var: zuul_task diff --git a/tasks/service.yaml b/tasks/service.yaml index e5fbcfe..efbba3c 100644 --- a/tasks/service.yaml +++ b/tasks/service.yaml @@ -73,6 +73,7 @@ when: zuul_file_zuul_server_service_src is not defined - name: Copy zuul service config into place. + become: yes copy: dest: "{{ zuul_file_zuul_service_config_dest }}" group: "{{ zuul_file_zuul_service_config_group }}" @@ -81,6 +82,7 @@ src: "{{ zuul_file_zuul_service_config_src }}" - name: Copy zuul-launcher service into place. + become: yes copy: dest: "{{ zuul_file_zuul_launcher_service_dest }}" group: "{{ zuul_file_zuul_launcher_service_group }}" @@ -89,6 +91,7 @@ src: "{{ zuul_file_zuul_launcher_service_src }}" - name: Copy zuul-merger service into place. + become: yes copy: dest: "{{ zuul_file_zuul_merger_service_dest }}" group: "{{ zuul_file_zuul_merger_service_group }}" @@ -97,6 +100,7 @@ src: "{{ zuul_file_zuul_merger_service_src }}" - name: Copy zuul-server service into place. + become: yes copy: dest: "{{ zuul_file_zuul_server_service_dest }}" group: "{{ zuul_file_zuul_server_service_group }}" @@ -105,6 +109,7 @@ src: "{{ zuul_file_zuul_server_service_src }}" - name: Enable zuul-launcher service. + become: yes service: enabled: "{{ zuul_service_zuul_launcher_enabled }}" name: "{{ zuul_service_zuul_launcher_name }}" @@ -113,6 +118,7 @@ when: zuul_service_zuul_launcher_manage - name: Enable zuul-merger service. + become: yes service: enabled: "{{ zuul_service_zuul_merger_enabled }}" name: "{{ zuul_service_zuul_merger_name }}" @@ -121,6 +127,7 @@ when: zuul_service_zuul_merger_manage - name: Enable zuul-server service. + become: yes service: enabled: "{{ zuul_service_zuul_server_enabled }}" name: "{{ zuul_service_zuul_server_name }}"