To run commands you need to specify the target. You can find more info about targeting here.
Also, you can check some examples below.
Perform a test.ping
in all minions:
sudo salt '*' test.ping
Create a directory in all minions running CentOS:
sudo salt -G 'os:Centos' file.makedirs /opt/cylance/
Copy a file from the salt-filserver to all minions running Centos version 6:
sudo salt -C 'G@os:Centos and G@osmajorrelease:6' cp.get_file salt://cylance/config_defaults.txt /opt/cylance/config_defaults.txt
You can find more info about compound targeting here.
You can make substitutions for rendering the commands with jinja, typing the value to be used between double curly brackets {{ … }}
.
Example:
Copy the appropriate version of CylancePROTECT install RPM from the salt-filserver, depending on the Centos os major release, using the grain osmajorrelease
:
sudo salt -C 'G@os:Centos' cp.get_file salt://cylance/CylancePROTECT.el{{grains.osmajorrelease}}.rpm /opt/cylance/CylancePROTECT.el{{grains.osmajorrelease}}.rpm template=jinja
Find out servers with 172.17.1.1 configured as DNS nameserver and show what nameservers are configured:
sudo salt -C 'G@dns:nameservers:172.17.1.1' grains.get dns:"nameservers"