Saltstack Cheat Sheet

Saltstack Cheat Sheet and Surviving Commands

In this tutorial will be sharing the main commands which can get you on the right track using salt. To learn how to install Salt click here for masterless install and here for the master and minion install.

Retrieve documentation from the system

salt '*' sys.doc    "This will retrieve the full documentation"

To pull specific section about 'pkg'  , 'network' ...etc just specify it after the command

salt '*' sys.doc network

Minions

Salt Minions ?

Minions are the slave servers of the salt master which you can control through the main Salt master server.

salt-run manage.status # What is the status of all my minions? (both up and down)
salt-run manage.up # Any minions that are up?
salt-run manage.down # Any minions that are down?
salt-run manage.alived # Show all alive minions
salt '*' test.version # Display salt version
salt '*' test.ping # Use test module to check if minion is up and responding.

Run Manifest and Target Specific Minion

salt '*' state.sls whatever # whatever.sls mainifest file will be applied to * "all minions"
salt 'server1' state.sls prod.somefile # prod/somefile.sls will be applied to server1 only

 

Salt Grains

What are Salt Grains?

Salt grains is the interface which has information about underlying system, like operating system, roles..etc. You can also create your own custome grain to get certain information within any of your minions.

salt '*' grains.ls "List all available grains"
salt '*' grains.item os     List the operating system in all the minions.
salt 'server1' grains.item roles  Show the roles only in the server called "server1"

 

Salt Jobs

Salt jobs are the requests/jobs running by Salt in any of the servers.

salt-run jobs.active # get list of active jobs
salt-run jobs.list_jobs # get list of historic jobs
salt-run jobs.lookup_jid <job id number> # get details of this specific job

 

Managing the System with SaltStack

Download Apache HTTPD package:

salt '*' pkg.download httpd

Check the status of service(s):

salt '*' service.status <service name>
salt '*' service.available <service name>
salt '*' service.start <service name>
salt '*' service.restart <service name>
salt '*' service.stop <service name>

 


Subscribe to
for video tutorials updates