From e9a4e0bd74ada6169d3515a68ac56880e7b42a50 Mon Sep 17 00:00:00 2001 From: Nick Maludy Date: Wed, 23 Dec 2020 09:01:39 -0500 Subject: [PATCH] Support for only installing select services on a node --- roles/StackStorm.st2/handlers/main.yml | 5 +++++ roles/StackStorm.st2/tasks/main.yml | 11 +++++++++-- roles/StackStorm.st2smoketests/tasks/main.yml | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/roles/StackStorm.st2/handlers/main.yml b/roles/StackStorm.st2/handlers/main.yml index b2b40213..a8211948 100644 --- a/roles/StackStorm.st2/handlers/main.yml +++ b/roles/StackStorm.st2/handlers/main.yml @@ -8,27 +8,32 @@ - name: reload st2 become: yes command: st2ctl reload --register-all + when: "'st2actionrunner' in st2_services" - name: restart st2actionrunner become: yes service: name: st2actionrunner state: restarted + when: "'st2actionrunner' in st2_services" - name: restart st2auth become: yes service: name: st2auth state: restarted + when: "'st2auth' in st2_services" - name: restart st2api become: yes service: name: st2api state: restarted + when: "'st2api' in st2_services" - name: restart st2stream become: yes service: name: st2stream state: restarted + when: "'st2stream' in st2_services" diff --git a/roles/StackStorm.st2/tasks/main.yml b/roles/StackStorm.st2/tasks/main.yml index 794147b7..507f5dbb 100644 --- a/roles/StackStorm.st2/tasks/main.yml +++ b/roles/StackStorm.st2/tasks/main.yml @@ -87,14 +87,13 @@ - name: Install additional Python packages into the st2 virtualenv become: yes pip: - name: "{{ item }}" + name: "{{ st2_python_packages }}" virtualenv: /opt/stackstorm/st2 state: present register: _task retries: 5 delay: 3 until: _task is succeeded - with_items: "{{ st2_python_packages }}" notify: - restart st2 tags: st2 @@ -142,6 +141,14 @@ loop: "{{ st2_services }}" tags: st2 +- name: Modify st2ctl to only control the given services + become: yes + lineinfile: + path: /opt/stackstorm/st2/bin/st2ctl + regexp: '^COMPONENTS=' + line: "COMPONENTS=\"{{ st2_services | join (' ') }}\"" + tags: st2 + # Since flush handlers does not support conditionals, we need to have a dedicated playbook # https://github.com/ansible/ansible/issues/41313#issuecomment-520891625 - name: Flush handlers to prepare StackStorm if there are packs to install diff --git a/roles/StackStorm.st2smoketests/tasks/main.yml b/roles/StackStorm.st2smoketests/tasks/main.yml index a7c74217..333f48b8 100644 --- a/roles/StackStorm.st2smoketests/tasks/main.yml +++ b/roles/StackStorm.st2smoketests/tasks/main.yml @@ -11,6 +11,7 @@ changed_when: no tags: - smoke-tests + when: "'st2actionrunner' in st2_services" - name: st2 installed command: st2 --version