You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to target highstate runs by state. This way I could, say, restart all apaches at the same time and be sure that I haven't missed any.
Like this:
salt -S apache state.highstate
Explanation: I write my states for, say, apache, with one basic state that sets everything that I want the same for all apaches (like the LogFormat, the mimesettings, etc) and include: that basic state from every other apache that gets deployed, however different its usecase may be.
When one is then confronted with something like the Heartbleed OpenSSL bug one would like to upgrade/restart all those apaches in one go.
I could work around this with pillar values but that feels like a kludge to me.
So what part of the state are you targeting with "apache"? The state ID? Is it supposed to include globbing? If you could clarify exactly what you want your example above to target, that would be really helpful.
etc, etc. You can see that I 'override', for example, /etc/apache2/sites in the machine-specific conf but leave lots of other states unaffected, so this way of writing configs is very useful to provide a default config that needs only small tweaks to be useful on different machines.
I'm not up to speed with the salt terminology, my use of 'apache' is referring to a filename, or rather a directory (apache/init.sls), but I guess a state ID (apache-pkgs, apache2, delete-apache-files) would work too.
I don't know how useful globbing would be, you'd need to be very careful with state naming.
So the targeting system is used for minion targeting, not for state targeting. In your example above, how would the master know which minions to target with the command?
Also, I may be missing something, but doesn't salt '*' state.sls apache fit your use case?
I'm asking for a command-line option. Parallel to salt -N [group] state.highstate, salt -L '[list-of-minions]' state.highstate, salt -G [grain] state.highstate, salt -I [pillar] state.highstate, etc.
And it's not that I want to run a specific state (your second question), I want to be unlimited ([insert evil laugh here]). To be specific further, no, it does not fit my use case, because the command you suggest would run the apache state on all minions, installing apache on all minions. I'd like it the other way around; to run a command on all minions that already have apache (or nginx or hiawatha or gcc or tomcat or whatever) installed (via a salt state of course).
To answer your first question: I thought that all commands were always sent to all minions and that the minion decides whether the command is meant for it or not. So it would not be the master that decides, it would be the minion that checks its list of states, sees whether it has the state in that list, and decides based on that whether it needs to run the command or not.
I think I'm following better, though I'm not sure if this is a feature that's reasonable given the way the state system is currently setup. I'll have to ping @thatch45 on it, see what he thinks.
I'm also looking for the same thing. We will often edit one or two states and want to get those changes deployed out -- in a large deployment it can be difficult to determine which machines will get a specific state (includes obscure this quite a bit). Doing a massive bulk salt '*' state.highstate isn't reasonable (because that can be a bit scary and, more practically, would take an absurd amount of time).
To clarify this requests we'd like to be able to do a "reverse lookup" of sorts where we can target by saying "find every machine that this state would apply to during a high state" and use those machines as the target.
Thanks for the idea! show_top doesn't give me what I want, but state.show_lowstate would, given some judicious grepping. (The bugreport above came from some experimenting :)
@Mrten Closing this due to age, the old version of Salt and Python 2.
Can you retest this with the latest release of Salt (currently 3006.3) and if still an issue, please open a new issue, which will have metrics in tracking issues.
This looks more like a feature request, if still interested, can you open a feature request using the new template, this allows for matrices from the template to track issues and allows for more information as to what problems are encountered or requested.
Activity
basepi commentedon Apr 14, 2014
So what part of the state are you targeting with "apache"? The state ID? Is it supposed to include globbing? If you could clarify exactly what you want your example above to target, that would be really helpful.
Mrten commentedon Apr 15, 2014
OK, so here's an example from my config tree that I've edited slightly for brevity so please don't expect all names to line up:
top.sls:machine/osm/apache/init.sls:apache/init.sls:etc, etc. You can see that I 'override', for example,
/etc/apache2/sitesin the machine-specific conf but leave lots of other states unaffected, so this way of writing configs is very useful to provide a default config that needs only small tweaks to be useful on different machines.I'm not up to speed with the salt terminology, my use of 'apache' is referring to a filename, or rather a directory (apache/init.sls), but I guess a state ID (
apache-pkgs,apache2,delete-apache-files) would work too.I don't know how useful globbing would be, you'd need to be very careful with state naming.
[-]target b [/-][+]target by state ID[/+][-]target by state ID[/-][+]feature request: target by state ID[/+]basepi commentedon Apr 17, 2014
So the targeting system is used for minion targeting, not for state targeting. In your example above, how would the master know which minions to target with the command?
Also, I may be missing something, but doesn't
salt '*' state.sls apachefit your use case?Mrten commentedon Apr 17, 2014
I'm asking for a command-line option. Parallel to
salt -N [group] state.highstate,salt -L '[list-of-minions]' state.highstate,salt -G [grain] state.highstate,salt -I [pillar] state.highstate, etc.Mrten commentedon Apr 18, 2014
And it's not that I want to run a specific state (your second question), I want to be unlimited ([insert evil laugh here]). To be specific further, no, it does not fit my use case, because the command you suggest would run the apache state on all minions, installing apache on all minions. I'd like it the other way around; to run a command on all minions that already have apache (or nginx or hiawatha or gcc or tomcat or whatever) installed (via a salt state of course).
To answer your first question: I thought that all commands were always sent to all minions and that the minion decides whether the command is meant for it or not. So it would not be the master that decides, it would be the minion that checks its list of states, sees whether it has the state in that list, and decides based on that whether it needs to run the command or not.
I hope I'm making more sense now...
basepi commentedon Apr 18, 2014
I think I'm following better, though I'm not sure if this is a feature that's reasonable given the way the state system is currently setup. I'll have to ping @thatch45 on it, see what he thinks.
jeff-minard-ck commentedon Nov 25, 2014
I'm also looking for the same thing. We will often edit one or two states and want to get those changes deployed out -- in a large deployment it can be difficult to determine which machines will get a specific state (includes obscure this quite a bit). Doing a massive bulk
salt '*' state.highstateisn't reasonable (because that can be a bit scary and, more practically, would take an absurd amount of time).To clarify this requests we'd like to be able to do a "reverse lookup" of sorts where we can target by saying "find every machine that this state would apply to during a high state" and use those machines as the target.
17 remaining items
stale commentedon Jan 8, 2020
Thank you for updating this issue. It is no longer marked as stale.
oeuftete commentedon Oct 7, 2020
ZD-5829.
wwalker commentedon Oct 7, 2020
Please add this.
The use case is very common (as said by jeff-minard-ck) #11868 (comment)
I currently do this in a script. roughly:
It is very handy, but also HEAVY.
Mrten commentedon Oct 7, 2020
Thanks for the idea! show_top doesn't give me what I want, but state.show_lowstate would, given some judicious grepping. (The bugreport above came from some experimenting :)
Some tweaking needed, but at least its going somewhere.
dmurphy18 commentedon Sep 25, 2023
@Mrten Closing this due to age, the old version of Salt and Python 2.
Can you retest this with the latest release of Salt (currently 3006.3) and if still an issue, please open a new issue, which will have metrics in tracking issues.
This looks more like a feature request, if still interested, can you open a feature request using the new template, this allows for matrices from the template to track issues and allows for more information as to what problems are encountered or requested.
Mrten commentedon Sep 26, 2023
oh, blah. see issue 65292