Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for only installing select services on a node #282

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions roles/StackStorm.st2/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,32 @@
- name: reload st2
become: yes
command: st2ctl reload --register-all
when: "'st2actionrunner' in st2_services"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Listing st2actionrunner might be very specific to implementation details in your environment.
Technically both st2api and st2sensorcontainer should have access to pack content as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The st2api service is "leaky" though. Given the way that this ansible setup works, you also need to install st2api on any host that has st2chatops because it is used to create the ChatOps API key.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could maybe do something like:

when: "'st2actionrunner' in st2_services and 'st2api' in st2_services"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about st2api or st2actionrunner or st2sensorcontainer? Technically, all these services should have access to the pack content.


- 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"
11 changes: 9 additions & 2 deletions roles/StackStorm.st2/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 (' ') }}\""
Comment on lines +147 to +149
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modifying /opt/stackstorm/st2/bin/st2ctl st2 core binary in-place is obviously not a good thing.

What are the alternative approaches here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only other thing i can think of is some way of identifying which services are supposed to be enabled on a host (thinking a config file, maybe st2.conf).

However, this would require changes to st2 core itself.

Relying on systemd themselves being enabled and grepping that output is unreliable as something or someone maybe have disabled a service that should be enabled.

I think this is a decent middle ground approach until we figure out if/how to support this in st2 core.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Expand Down
1 change: 1 addition & 0 deletions roles/StackStorm.st2smoketests/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
changed_when: no
tags:
- smoke-tests
when: "'st2actionrunner' in st2_services"

- name: st2 installed
command: st2 --version
Expand Down