Closed ooCHUBSoo closed 1 year ago
Answer for future reference:
Targeting works the same way with the StackStorm pack as it does with Salt since StackStorm passes these parameters to Salt for processing. Compound targeting is documented here https://docs.saltproject.io/en/latest/topics/targeting/compound.html
As an example, to see the OS version of minions running Ubuntu, the compound statement would be:
st2 run salt.local module='grains.item' args='osrelease' target='G@os:Ubuntu and E@automate.*' tgt_type="compound"
action.ref: salt.local
context.user: stanley
parameters:
args:
- osrelease
module: grains.item
target: G@os:Ubuntu and E@stackstorm.*
tgt_type: compound
status: succeeded
start_timestamp: Sun, 05 Feb 2023 10:07:27 UTC
end_timestamp: Sun, 05 Feb 2023 10:07:28 UTC
result:
exit_code: 0
result:
return:
- stackstorm1.example.com:
osrelease: '20.04'
stackstorm2.example.com:
osrelease: '20.04'
stackstorm3.example.com:
osrelease: '20.04'
st2 run salt.local module=test.ping tgt_type=grain target='os:Ubuntu'
The above works but only accepts 1 grain.
How can I get this to work with compounded grains list?
ex.
st2 run salt-local module=test.ping tgt_type=grains target='os:Ubuntu AND env:prod'
Ideally, would like to have the above return all machines that match these grains.
Any suggestions as to where to start with this would be appreciated.