Currently salt can target minions in a number of ways. The only "list" way is a comma-delimited list.
A useful target method would be a file containing a list, one per line. This would be similar to the grep -f flag.
I would suggest, to keep with salt's current flag schema, that the flag be -F --file
What about using Node Groups where you can save your minions inside the master configuration as groups.
@Code-Vortex Good idea, but not quite what I am looking for. I often need to target a list of minions that I will not know in advance. Usually I have this list as a file - and I can either convert it to a comma delimited list, or run a for-loop in sh/bash on it. Being able to directly target the contents of the file would be a great convenience.
@nbirnel, thanks for the feature request.
+1
What is the status of this request?
lets say you have the following file minions.txt containing list of minions as follows:
minion_02
minion_03
Now you can call test.ping on these minions by the following command line
salt -L `awk -vORS=, '{ print $1 }' minions.txt | sed 's/,$/\n/'` test.ping
The result would be:
minion_01:
True
minion_02:
True
minion_03:
True
This is just a workaround until we have it as a feature.
Excellent! Thank you @mostafahussein
Given a text file of the name minions.txt in this format:
minion1
minion2
minion3
This command:
salt -L "$(cat minions.txt)" test.ping
Would produce this output:
minion1:
True
minion2:
True
minion3:
True
The -L option, apparently, allows the list of minions to be delimited by commas or newline characters.
@tlovely, could you post the content of your minion.txt ? I guess its a comma separated, am i right ? As the command I have posted above converting a list to comma separated in order to make it work with salt
@mostafahussein I updated my comment. Thanks.
@tlovely That takes care of my use case perfectly. I retract the feature request, but this behavior is undocumented. @jfindlay, should I submit a new documentation issue, or leave this open?
@tlovely, or even
salt -L "$(<minions.txt)" test.ping
@nbirnel, it does seem to be documented:
# salt --help | grep -A2 -- '--list'
-L, --list Instead of using shell globs to evaluate the target
servers, take a comma or space delimited list of
servers.
@jfindlay I do not read that as documenting newlines.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.
Most helpful comment
lets say you have the following file
minions.txtcontaining list of minions as follows:Now you can call
test.pingon these minions by the following command lineThe result would be:
This is just a workaround until we have it as a feature.