ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Executing Basic Commands with Salt

    IT Discussion
    salt salt open sam salt open devops
    1
    1
    1.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • scottalanmillerS
      scottalanmiller
      last edited by

      Salt shines with rapid, parallel remote command execution capabilities. With can execute commands using the salt command. Salt has its own command capabilities as well as having the ability to run native commands as if we were at the shell.

      First, native commands are simple to run:

      salt '*' cmd.run 'uptime'
      

      This executes the command uptime on all of the machines listed in the environment. The first argument is the wildcard * which tells us that every machine will run the command. The cmd.run argument tell Salt to run a raw command and the final argument is the command itself.

      Second, we will run a native command. Salt has many useful built in commands that we can run. We will show a couple of examples here:

      salt '*' disk.usage
      

      This returns the disk usage details from each machine in the environment. Of course, instead of using the wildcard we could target a specific machine or group of machines. Here we will run the same command but only on the machine names minion2.

      salt 'minion2' disk.usage
      

      We can use Salt's command execution capability to "manually" install a package to an individual machine (or group of machines or every machine, of course.)

      salt 'minion3' pkg.install wget
      

      Very useful. With the salt command we can replace tedious and slow SSH sessions and remote logins with something more secure, less effort and much faster. On a single machine, this is relatively unimportant. Once we start to tackle multiple machines this becomes rapidly more useful, even in a non-DevOps style mode. We can do most system administration tasks directly in this way, but with less effort and more efficiency. In this way, our Salt Master can become rather like a Jump Box but with some very handy benefits.

      Now we will list available, network interfaces:

      salt '*' network.interfaces
      

      Welcome to just the beginning of the power of Salt!

      1 Reply Last reply Reply Quote 2
      • 1 / 1
      • First post
        Last post