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

Conversation

nmaludy
Copy link
Member

@nmaludy nmaludy commented Dec 23, 2020

This Ansible module supports only installing/running select services by specifying the st2_services variable. However, when doing so it causes issues in various cases because, for example, things like st2ctl reload --register-all can only be run on a st2actionrunner node where the pack content is available. If you're on a node just running st2api this command is going to fail.

This change does the following:

  • Implements some simple when conditions for various handlers to only restart services when they are necessary
  • Fixes st2ctl on the node to only contain the specified services in its COMPONENTS variable, so that st2ctl command still work as expected! :)
  • Fixes a small deprecation warning on the pip PR i did yesterday:
[DEPRECATION WARNING]: Invoking "pip" only once while using a loop via squash_actions is deprecated. Instead of using a loop to 
supply multiple items and specifying `name: "{{ item }}"`, please use `name: '{{ st2_python_packages }}'` and remove the loop. 
This feature will be removed from ansible-base in version 2.11. Deprecation warnings can be disabled by setting 
deprecation_warnings=False in ansible.cfg.

@armab i'm thinking about also adding some when conditions to the st2smoketests where appropriate. Could you help me figure out what the conditions should be there?

Thanks!

@nmaludy nmaludy self-assigned this Dec 23, 2020
@pull-request-size pull-request-size bot added the size/S PR that changes 10-29 lines. Very easy to review. label Dec 23, 2020
@nmaludy nmaludy force-pushed the feature/select-services branch 2 times, most recently from 9ee2ff7 to effe6bb Compare December 23, 2020 14:12
Copy link
Member

@arm4b arm4b left a comment

Choose a reason for hiding this comment

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

Thanks, @nmaludy.

As I recall, st2_services was added just to help with identifying services we needed to restart depending on a st2 version. This is relevant to releases when workflowengine was added and so on.

Interesting that it's now helpful for the HA compatible work. I left a couple of comments to address.
Smoke Tests seem to pass OK so no problem there.

Comment on lines +147 to +149
path: /opt/stackstorm/st2/bin/st2ctl
regexp: '^COMPONENTS='
line: "COMPONENTS=\"{{ st2_services | join (' ') }}\""
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.

@@ -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.

@CLAassistant
Copy link

CLAassistant commented May 11, 2022

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature size/S PR that changes 10-29 lines. Very easy to review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants