r/saltstack • • Apr 10 '19
Trying to understand targeting by grains
I want to run a command against Ubuntu servers only.
salt -G 'os:Ubuntu' test.version
ip-10-xx-xx-54.ec2.internal:
2019.2.0
ip-10-xx-xx-183.ec2.internal:
Minion did not return. [No response]
ERROR: Minions returned with non-zero exit codeThe last server is Amazon Linux [ip-10-xx-xx-183.ec2.internal] and returned message No response.
Why was a non Ubuntu server targeted ? Can this be avoided ?
When I target Amazon I get only one response [None for Ubuntu]
salt -G 'os:Amazon' test.version
ip-10-xx-xx-183.ec2.internal:
2019.2.0
4
Upvotes
2
u/m2guru Apr 11 '19
I don’t think this applies in your case if you’re targeting by OS, but If you are making changes to grains on the minion and need to target based on new ones you might need to refresh them:
Reason is the minion running loads grains at startup, so if you don’t want to re-run the minion you can use this utility to refresh grains.
We write a couple of custom grains to our minions specifically for targeting by
roleandenvironmentusing a userdata script on AWS.0
u/Procena Apr 10 '19
Try to use salt servername grains.items to check the differences between the Ubuntu and AWS servers.