Solved Beginner SaltStack Question: Can minions be placed in folders or groups ? (Coming from AD perspective)
-
Hi,
To the title say its all, i am learning more and more about SS, especially for AD alternative.
till know I love what I see, not just like.
I wonder wondering If I have currently 3 minions, for example:
[root@salt ~]# salt '*' test.ping
172:
True
123:
True
vm:
Minion did not return. [Not connected]Can I place minion 172 and minion 123 in certain group or folder ? like you would do with AD ?
So when I type a command :
salt 'GROUP X' cmd.run 'del C:\opera.exe'
I can launch this command on 172 + 123 ?
Many thanks in advance for continual support.
Perhaps when I finish I will write a tutorial.
-
@msff-amman-Itofficer
This might help you. https://docs.saltstack.com/en/latest/topics/targeting/index.html -
There are all kinds of ways to put them in groups. You can use simple regex on hostnames, you can define groups and so forth. Quite powerful and flexible.
-
The simplest is hostname regex and lots of shops do this. In NTG we have a naming convention like this...
dny-lnx-lamp1
That tells us the datacenter, operating system family and application purpose. To use groups I could do things like...
salt 'dny-*' .... salt '*-lnx-*' ..... salt '*-lamp*' .....
The first example would use the group for "any server at the dny datacenter.". The second would be "all Linux servers." The third would be "just lamp application stack machines." You can put them together, too, like this...
salt 'dny-lnx-lamp*' ....
So that it would only target Linux based LAMP stack application servers at dny but would get all of them, because there might be lots of them.
-
@msff-amman-Itofficer in your specific example you can easily pass a list of hosts you want to target
salt -L '172,123' test.ping
If you would like to define a more long term list of minions you can use nodegroups. Define your nodegroups in your master config file
/etc/salt/master
:nodegroups: group1: - 172 - 123 group2: L@172,123
Both groups target the same minions but with a different syntax, you can use the one you prefer. Group1 is using a YAML list and group2 is using compound matchers. With your nodegroup defined you can now target it as follows:
salt -N group1 test.ping
Saltstack has lots of targeting options you should check the docs to better understand them.
-
-
@msff-amman-Itofficer said in Beginner SaltStack Question: Can minions be placed in folders or groups ? (Coming from AD perspective):
ohh shit, how did that get passed me...
Great, thanks again.