Frequent Commands

Most commands support globbing and regex matching on Minions and Grains to execute commands. See Common Issues for additional debugging information.

Note

For windows minions, command should be run from the salt batch files to setup the appropriate environment.

Linux command.
salt-call -l debug state.highstate saltenv=dev pillarenv=dev
Equivalent Windoes command.
c:\salt\salt-call.bat -l debug state.highstate saltenv=dev pillarenv=dev

General Master Commands

Run Command On Minions From Salt Master

salt {MINION} cmd.run 'ifconfig'
salt -G os:ubuntu cmd.run 'df -h'

Get Status of All Minions

salt-run manage.status

Show Minions On A Subnet

salt -S '10.5.5.0/24' network.ip_addrs

Show Avaliable Grains On Minions

salt {MINION} grains.items

Jobs

All commands executed are placed into the job queue with results cached on the salt-master.

Important

The CLI results read poorly and may initially appear that jobs fail with the message:

Minion did not return. [No response]

This is just stating that the remote command did not respond before the CLI timed out. It is automatically added to jobs when executed and results are cached for 24 hours by default.

List jobs that have run.
salt-run jobs.list_jobs
Show results from job that has completed.
salt-run jobs.lookup_jid {ID}

List Active Jobs

salt-run jobs.active

Note

Useful for long-running comamnds (e.g. ‘no response’ commands) where the command will not finish before timeout is reached. See jobs and Minion did not return. [Not connected]..

Generate New Master Certificates

Salt Master uses a RSA 4096bit key and a OpenSSL public key.

ssh-keygen -t rsa -b 4096 -f master.pem
openssl rsa -in master.pem -pubout -out master.pub

Note

These keys should have no password. Replace existing files in /etc/salt/pki/master and ensure Minions are updated accordingly. See Minion Security Section.

General Minion Commands

Useful for testing as well as immediately applying changes outside of the minion run window.

Run A Specific State

Useful to isolate failures or apply a specific state change.

sudo salt-call -l debug state.sls {STATE NAME} pillarenv=dev saltenv=dev

Manual Minion Run with Specific Environments

salt {MINION} state.highstate pillarenv=dev saltenv=dev
salt-call state.highstate pillarenv=dev saltenv=dev