You'll learn how to:
Estimated time: 5 minutes
After your systems are added to the roster, you are immediately ready to run shell commands, update packages, and distribute files to all targeted systems simultaneously. As a bonus, all responses are returned in a consistent, configurable format so you can easily see what did and didn’t work.
Salt lets you remotely execute shell commands across multiple systems using
salt-ssh '*' cmd.run 'ls -l /etc'
All targeted systems simultaneously and immediately execute this command and then return the output to the Salt master. Feeling the power?
While shelling out using
cmd.run is certainly useful, the real power comes when you add Salt execution functions. The Salt community has put tremendous effort into creating hundreds of functions that simplify most management tasks. Even better, the same function can be used consistently across all supported platforms.
Resist the urge to shell out. Learn the ways of the Salt execution functions.
salt-ssh '*' disk.usage
salt-ssh '*' pkg.install cowsay
salt-ssh '*' network.interfaces
These are just a few examples of the many execution functions available.
All of the remote execution commands in this section can be executed in your demo environment. These examples match all systems in your roster using the
* glob, but you can substitute this with the ID you assigned in the
roster file instead:
salt-ssh 'managed' network.interfaces
You can also pass a comma-delimited list of systems:
salt-ssh 'server1,server2,server3' network.interfaces