1

I am using SaltStack on my linux boxes and want to define nodegroups. I know about compound matching and minion lists, etc.

This is what I need, and it works this way, but that's hard to maintain with lots of servers

nodegroups:
  group1: 'srv1,srv2,srv3,srv4,dev1,dev2,stage1,stage2'
  

To keep it simple, I'm trying to define them this way:

nodegroups:
  group1: 'srv*,dev*,stage*'

But I can't find a way to do this right. Any ideas?

-=EDIT=-

I tried Dan Garthwaites solution, but it didn't work. I even tried it on my private dev server, which has Salt version 2014.1.4 installed. This is what I get.

Trying as normal list (full hostnames)

fmohr@salt-master:~$ sudo salt -v -C 'L@dns01,apache' test.ping
Executing job with jid 20140708072832751715
-------------------------------------------

dns01:
    True
apache:
    True

with one wildcard

fmohr@salt-master:~$ sudo salt -v -C 'L@dns*,apache' test.ping
Executing job with jid 20140708072837257646
-------------------------------------------

apache:
    True

with all wildcards

fmohr@salt-master:~$ sudo salt -v -C 'L@dns*' test.ping
No minions matched the target. No command was sent, no jid was assigned.

fmohr@salt-master:~$ sudo salt -v -C 'L@dns*,apach*' test.ping
No minions matched the target. No command was sent, no jid was assigned.

I don't think you can use wildcards in lists, but I have no clue how to get salt to target dns* and apach* (as an example).

3 Answers 3

3

you should use or to connect them, like this:

nodegroups:
    group1: 'srv* or dev* or stage*'

salt -C 'srv* or dev* or stage*' test.ping

tested on my machine.

1
  • I could swear I tried that and it didn't work, but it did now so thanks.
    – mohrphium
    Jul 23, 2014 at 8:06
2

Node groups use compound matching as defined here:

http://docs.saltstack.com/en/latest/topics/targeting/compound.html

Your answer is:

nodegroups:
  group1: L@srv*,dev*,stage*

Keep in mind you can also use grains and/or pillars to target minions via the compound matcher.

2
  • Any luck @mohrphium? Feb 2, 2015 at 2:49
  • Ah, sorry. If Iremember correctly your answer was correct although there was something else preventing me. Not sure anymore what it was though.
    – mohrphium
    Feb 2, 2015 at 7:07
0

I did it with grains now. I just added

grains:
  group: groupname

in the /etc/salt/minion.d/minion.conf on my minions. It's not really what I wanted since this defines which roles the minion gets on the minion side, which is not optimal from a security perspective (plus it would be more convenient to define all groups on the master.)

On the plus side, I can set the grain for servers that don't belong to any groups to undefined and it's easier to get a list of all undefined servers.

Thanks for the help. I'll let this stay as unresolved, since it's not really solved (if someone knows how to do this on the master, please tell me)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .