Repository navigation
Allow minion_id to be specified for certain match functions - #11965
Conversation
This commit allows the minion ID to be specified for the functions in salt/modules/match.py which operate on the minion ID (compound, list, pcre, glob). Before, they would just use the value of __opts__['id'], which makes these functions fail to work properly when run from within Pillar SLS files, due to Pillar evaluation taking place on the master (and thus __opts__ referring to the master opts instead of the minion opts). By adding a minion_id argument to these functions, the ID can be overridden, and thus be specified using the 'id' grain in Pillar SLS files.
|
Refs #11517 |
|
Hold off on merging for now, this still needs some discussion. |
No need to force the user to submit the ID, just grab it from grains. Still allows for minion ID to be passed on the CLI.
|
OK, I've made a change and updated the pull request message above with more information. Should be good to merge, pending review. |
|
Test Failed. If the failures are unrelated to your code, don't stress, a core developer will know these apart. |
|
I like this. +1 |
Allow minion_id to be specified for certain match functions
|
@cachedout and @terminalmage is this solution using the |
|
@steverweber #12128 ensures that the grains['id'] matches the id used to auth with the master. So we're good now. Thanks for pointing out that problem. |
Rather than use the initial approach for this PR, I've updated it so that it grabs the minion ID from
__grains__rather than expecting it to be overridden. This, in my opinion, is better than expecting users to manually override the minion_id in their Pillar SLS files. It still preserves the added functionality of overriding the minion ID, while operating as one would normally expect it to when not overridden (i.e. using the minion's ID by default, even when used from Pillar SLS files).More detailed reasoning on this approach below, followed by the original commit msg.
Detailed reasoning for grabbing minion ID from
__grains__The match functions which operate on the minion ID don't use anything from
__opts__other than the minion ID, and they don't call any of the execution functions from__salt__, either. The match types that operate on the minion ID (which were the only ones that I modified in my pull request) just evaluate regexes, globs, etc.Therefore, instead of passing
__opts__when instantiating the Matcher class instance, instead a bare-bones dictionary containing just the ID is passed (aside frommatch.compoundwhich also gets the grains). For example:So, the pull request still allows the minion ID to be passed in on the CLI to override the ID against which the match expression is evaluated, but if left out, it uses the value from
__grains__['id'].Original commit message
This commit allows the minion ID to be specified for the functions in
salt/modules/match.py which operate on the minion ID (compound, list,
pcre, glob). Before, they would just use the value of
__opts__['id'],which makes these functions fail to work properly when run from within
Pillar SLS files, due to Pillar evaluation taking place on the master
(and thus
__opts__referring to the master opts instead of the minionopts).
By adding a
minion_idargument to these functions, the ID can beoverridden, and thus be specified using the
idgrain in Pillar SLSfiles.