Skip to content

Instantly share code, notes, and snippets.

@rajanm
Last active March 31, 2020 06:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajanm/b8e22447ef60cf4547e38384d5c90f41 to your computer and use it in GitHub Desktop.
Save rajanm/b8e22447ef60cf4547e38384d5c90f41 to your computer and use it in GitHub Desktop.
Sample salt commands to be run from a salt master. These commands have been tested with salt 2017.7.4 (Nitrogen).
# install a tool in all minions connected to a salt master.
sudo salt '*' cmd.run 'sudo apt-get install nmon -y'
# run a linux command in all minions connected to a salt master.
sudo salt '*' cmd.run 'date'
# check if a system reboot is required in all minions connected to a salt master.
sudo salt '*' system.get_reboot_required_witnessed
# get minion hostname in all minions connected to a salt master.
sudo salt '*' network.get_hostname
# get the list of system information across all managed systems (running minions)
sudo salt '*' grains.ls
# get the values for the system information across all managed systems (running minions)
sudo salt '*' grains.items
# install python3 to enable pip to run in all minions connected to a salt master.
sudo salt '*' cmd.run 'sudo apt-get install python3-pip -y'
# install a python module in all minions connected to a salt master.
sudo salt '*' cmd.run 'pip3 install progressbar'
# test a echo message from all minions connected to a salt master.
sudo salt '*' test.echo 'hello'
# ping each minion connected to a salt master.
sudo salt '*' test.ping
# get minion environment details from all minions connected to a salt master.
sudo salt '*' grains.items --output=pprint
# update and upgrade linux packages in multiple servers simultaneously. all server names should have the string 'node' in them.
sudo salt '*node*' cmd.run ' sudo apt-get update | sudo apt-get upgrade -y ' --output=pprint
# view and debug events in the salt master and minions
sudo salt-run state.event pretty=True
# run salt minion in debug mode
sudo salt-minion -l debug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment