-
-
Notifications
You must be signed in to change notification settings - Fork 746
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
Disable/Enable Sensors/Rules/Aliases via blacklisting/whitelisting in pack config #3973
Comments
+1 Some things that i'm thinking about:
Brainstorming global config---
st2:
rules:
defaults:
- name: *
enabled: false
exceptions:
- name: backups.full_backup
enabled: true
aliases:
defaults:
- name: *
enabled: false
exceptions:
- name: st2.*
enabled: true Brainstorming pack config---
menandmice:
dev:
server: menandmice.dev.domain.tld
username: user
password: "{{ st2kv.system.menandmice.password }}"
st2:
rules:
exceptions:
- name: menandmice.discovery
enabled: true
aliases:
exceptions:
- name: menandmimce.*
enabled: true |
@nmaludy thanks for brainstorming this! From that ^^ example, I definitely like the first two levels of definition: ---
st2: # as a core-reserved key
rules:
aliases:
sensors: need to think more about the rest to make it more obvious & clear & easy. |
ProblemCurrently actions, aliases, rules and sensors (called items) installed in a pack Example: Example #2: Potential SolutionsIn the spirit of StackStorm we would like to implement a solution in the ---
<pack_name>:
actions:
...
aliases:
...
rules:
...
sensors:
...
orion:
aliases:
...
rules:
...
linux:
actions:
...
sensors:
... Item defintions will be the same for each item type (actions, aliases, rules and ---
# disable all aliases in the st2 pack
st2:
aliases:
default:
enabled: false To support both whitelisting and blacklisting we will have a Whitelisting ExampleHere all aliases in the ---
st2:
aliases:
default:
enabled: false
exceptions:
- name: st2_actions_list
enabled: true
- name: st2_rules_list
enabled: true Blacklisting ExampleHere all aliases in the ---
packs:
aliases:
default:
enabled: true
exceptions:
- name: pack_install
enabled: false If this is not enough flexibility we can extend this same concept to Global Config
Schema---
type: object
description: >
Keys are pack names, values contain global config information
parameters:
actions:
"$ref": "#/definitions/config_obj"
aliases:
"$ref": "#/definitions/config_obj"
rules:
"$ref": "#/definitions/config_obj"
sensors:
"$ref": "#/definitions/config_obj"
definitions:
config_obj:
type: object
properties:
default:
type: object
description: >
The default values for the parameters on the action/alias/rule/sensor
properties:
enabled:
type: boolean
description: "Are item instances enabled by default."
default: true
exceptions:
type: array
description: >
List of items that are different from the default
items:
type: object
properties:
name:
type: string
description: "Name of the item (glob patterns accepted)."
enabled:
type: boolean
description: "Is the item instance enabled." Example---
# example: whitelist
# disable all aliases in the st2 pack except st2_executions_list
st2:
aliases:
default:
enabled: false
exceptions:
- name: st2_executions_list
enabled: true
# example: blacklist
# enable all aliases in the duo pack except 'auth_auth' and 'auth_demo'
# also disable the auth_wrap_demo action
duo:
aliases:
default:
enabled: true
exceptions:
- name: auth_auth
enabled: false
- name: auth_demo
enabled: false
actions:
default:
enabled: true
exceptions:
- name: auth_wrap_demo
enabled: false
# disable all sensors in the linux pack (file_watch_sensor)
linux:
sensors:
default:
enabled: false |
If we introduce something called global config @nmaludy proposing, I'd suggest:
It's easier to manage infra-as-code when specific pack config is responsible to enable/disable only content it holds (actions,aliases,etc by name). Another adjustment is simplifying the schema/defition: Instead of: duo:
aliases:
default:
enabled: true1
exceptions:
- name: auth_auth
enabled: false
- name: auth_demo
enabled: false Something along the lines: duo:
aliases:
default: enabled
disabled:
- auth_auth
- auth_demo and duo:
aliases:
default: disabled
rules:
default: disabled
actions:
default: enabled or any other way to simplify the definition if that makes sense to anyone. |
Someone using StackStorm + Infra as code in a real production environment will be aware about this feature. It bug us all the road in our own #ops work running StackStorm in production (it's actual for Docker story too), that's why the feature request is here. The problem is almost every Exchange pack which comes with a bunch of enabled by default sensors/aliases/rules and so unconfigured sensors or rules you don't want are taking system resources, spamming in logs or weaken chatops security by exposing aliases you can't blacklist. At the moment there is no mechanism to change this behavior in StackStorm: persistently enable or disable specific pack content in a more granular way (only fork pack or delete rules/sensors by hand which reverts after packs reinstall from Exchange). @StackStorm/team please provide your opinions in this issue, as @nmaludy is considering to implement this and looking for more feedback to get the design/idea accepted. |
@armab The reason why i created the schema like: duo:
aliases:
default:
enabled: true Was to allow for future extension in case other properties wanted to be overloaded and/or configured. I do like your idea of the aliases:
default:
enabled: false
sensors:
default:
enabled: false |
Where did this end up? Looking to do something similar |
I’d like to color in this discussion. Ignoring actions for a moment - for sensors and rules - I think it makes the most sense to think of them like Linux services. And separate enabled out from their config. There is literally never a use case which 100% of users want a sensor or rule enabled by default, and defaulting to disabled / false is the Linux thing to do. There could be a pack install flag that enabled things, but I think this actually would remove a ton of tricky logic vs. a more straightforward implementation. Although there would need to be some state work done, but my guess is that’s already in the DB. |
When orgs/groups are building custom packs for their specific needs, - it's a common case when all sensors, rules, action aliases are enabled and needed from the pack installation straight away. The point behind pack configs is to allow users to enable/disable specific sensors, rules, action aliases in a granular way and follow the infrastructure as code approach, which StackStorm believes and preaches everywhere in its design. This also conforms with the st2 mechanics as pack validation/db sync/configuration happens on pack content registration stage. This way pack configuration could be also changed on |
The discussion in this thread is really interesting. I think about this for 2 days and am still not sure if it's relevant and an actual use-case or not so I just add my 2ct here: Can't there be a 3rd case beside enabled and disabled? Something like package-default? At the same time I see arguments for and against the package-default option and that it adds an additional layer of complexity. Now I'm curious what you think about it. |
I’m dropping this thought here while I’m thinking of it: it would be interesting to consider having pack modes: say - production and community. Where the community mode allows overwriting and production does not. |
Coming back to this one again... I'm not too sure on the global idea applying to all packs. Presumably with the global the precedence would have been:
But if I'm using community packs and my own, then if I want to disable all pack sensors apart from the ones I've wrote, then I would end up having to specify the override in configs/global to disable them all, and then put them back in on the packs I want under packs/configs/pack.yaml. So I'm not sure of the value of having a fully global across all packs, and think it might be easier to use if we always specify at a pack level (whether that be in global.yaml with the pack name) or under configs/pack/config.yaml with the syntax where pack name is not needed. I'd therefore be up for going for one of these options:
Thoughts? I'd be quite interested in taking a look at this if I get a chance... |
A single The order of evaluation (last value set wins) would be the following: Taking the
The When talking about the pack being mirrored in the configuration directory, I'm suggesting that the structure and content be managed outside of StackStorm. The only thing StackStorm would do is continue to write pack configuration files at the root level and parse any directories/files inside the
The override files are linked by
This example would only override the |
Interesting point above. @nzlosh The drawback I see with mirroring the whole structure makes it a bit more difficult to do wildcard overrides. e.g. I quite often want to install a pack but disable all its sensors. If I have to mirror the structure I have to add a disable on each sensor for example, and each time something new is added to the pack and I install a new version, I have to check what has been added - so it makes it harder to do wildcard overrides. So I personally would prefer the configs//config.yml with contents similar to:
But the advantage of the mirroring is that it makes it easier to do config overrides, e.g force parameters to be mandatory for example, as that would be on a per action etc. And I can see the use for that, for example if a pack supports multiple ways of doing an action, you could use the overrides to disable parameter combinations you don't want to use. So perhaps there is a need for both the mirror but also to support wildcards (perhaps at the appropriate directory level, e.g. sensors/rules etc). So perhaps have the mirror that @nzlosh proposed but also the ability to do wildcard at the sensor level, e.g. with parmaeters that apply to all sensors in that pack, e.g.
So then priority would be: 1st. default state from st2 core But I'm also concerned that this makes it overly complicated. It helps when I want to wildcard all sensors, but complicates the logic. So not sure if its necessary or not, and instead if should just cope with having to explicity override each sensor to disable them all? |
I see what you mean about having global overrides being more convenient. I had a simple shell script in mind to do bulk changes which gives an approximation to global behaviour: e.g.
Perhaps a small Python script could be developed as a helper for managing the override settings? Or even integrated into the st2client.
This would create the config override in the right place for all sensors registered in the email pack with provided key/value pairs. |
This one is near and dear to my heart as we have been bit by the issue of sensors being enabled/disabled in different environments by a pack install. We started working on a solution to this that used a workflow to enable/disable sensors after packs were loaded and I think it may solve all these issues in a simpler, more accessible manner than processing it in the code with the global configs with pack level overrides. Some simple enhancements to the base workflow could be to have it read the current sensor status from the DB (check to see if an operator clicked the disable button in the GUI) and then re-install the sensor from the pack with the same state. This simple change alone would prevent a number of issues in how the system currently works and would likely be simple to implement in the workflow. Maybe add some global variables to the "st.conf" file associated with the system in use that were included in the workflow context so those global values could be used during the processing of the sensor workflow. This would allow the SysAdmin the ability to "tag" the system as DEV/QA/PROD and using that value in the workflow to branch as needed. These values could likely be used as the basis for global overrides if the workflow was implemented correctly. Along with the global variables inserted into the workflow context, maybe enhance the pack variables inserted into the workflow context as well so tags could be applied to Exchange packs or internally developed packs and could be processed differently in the workflow as needed (or as deemed fit by security). These values could be used as the basis for pack level overrides. Finally, a pack of workflows could be developed and shared on the Exchange where various sensor enabling/disabling workflows could be shared across the community and provide examples/enhancements to the base workflow that would make the process more accessible to new users. Most of what I suggest is specific to sensors but I would imagine would apply to rules/aliases as well with a similar manner assuming the APIs for each supported what is needed to process them in a workflow. |
I get the idea is to manage the state of pack content in the workflow level behind the pack install. With that, I'm 👍 to what @nmaludy proposed and @amanda11 raised once again. |
@armab What's your opinion on @nzlosh proposal of mimicing the structure as a override. This has the benefit of making it easier to update config as well as enabled/disabled, but has the disadvantage of harder to do global overrides. I'm quite tempted by @nzlosh's proposal @ #3973 (comment) |
@amanda11 I think there's too much nesting and messing with the dirs/files if we go that way with mimicking the full pack structure. It looks too verbose to me, and may also have some leftover and untracked configs in the case when pack content is changed/removed/renamed/moved. Management is more encouraged to get messy. Another point, this duplication might lead to confusion which config to edit really for content overrides. The first obvious idea is looking at email.yaml, while it's really overrides at a deeper level:
It doesn't address the case when the user wants to blacklist all sensors in the system, but whitelist sensors only for some specific packs. And so instead of that, I believe configuration like
to define the enabled/disabled pack content globally + per pack looks balanced enough. You really want to configure things in a fewer places, instead of jumping between the dirs. |
I'll see if I can start working on this in the background, going to start at the pack level first, also thinking perhaps would be more clear to put the overrides into a configs/overrides sub-directory so its clear the point of them. |
This was discussed for several times and was an issue more than a few times internally and in #community as well.
Infrastructure as a code is cool if you control the entire code, but StackStorm exchange has packs with Sensors, Rules, Aliases which are enabled by default. This brings a lot of noise after installing a pack.
The worst, - when we change the sensor locally to
enabled: false
, next pack re-installation or re-provision replaces that change and st2ctl reload brings sensor or whatever back online.Same problem is when vice-versa content is disabled by default in Exchange Pack and we want to enable it in our system.
The proposal is to have a mechanism to optionally blacklist/whitelist Sensors, Rules, Aliases via pack config which will take precedence over the metadata with possibility to include/exclude specific content to be registered or disabled with enable-many, disable-many, enable-one, disable-one, glob logic.
This way we could keep infrastructure as a code via existing
/opt/stackstorm/packs/<pack>.yml
definition.This will solve #3016 and help with #3963 as well as other issues related to pack content registration.
The text was updated successfully, but these errors were encountered: