About Archive Other Contact

First Salt commands after initial install on FreeBSD

This is the 4th post in the SaltStack on FreeBSD series and continues on the work we have done in the first 3 posts. So far we have:

This post documents SaltStack commands to be performed on the master and minion to show SaltStack capabilities using its modules. This post will NOT explain setting up a SaltStack state and deploy it on the minion. This is left for the next post.


The following requirements have to be in place to be able to implement what is described in this post:

Some starting points

The commands shown in the next chapter use the following configuration:

Commands on the master

List minions with salt-key

To list the minion with the salt-key command use:

# salt-key -L

Test if minion is up and responding

To test if the minion is up and responding with the test module use the command:

# salt 'minion.intra.domain.org' test.ping

To test all minions registered with the master use the command:

# salt '*' test.ping

Return the version of Salt on the minion

To return the version of Salt on the minion use the command:

# salt 'minion.intra.domain.org' test.version

Run adhoc commands on the minion

One of the functionalities I like very much about Salt is its abilty to run adhoc commands on the minion. This can be done through the cmd module and its run function.

To show the version of FreeBSD:

# salt 'minion.intra.domain.org' cmd.run 'uname -r'

Or to show the known vulnerabilities of the packages on the minion:

# salt 'minion.intra.domain.org' cmd.run 'pkg audit -F'

Or upgrade the packages on the minion:

# salt 'minion.intra.domain.org' cmd.run 'pkg upgrade -y'

And you can even restart the salt_minion service on the minion from the master:

# salt 'minion.intra.domain.org' cmd.run 'service salt_minion restart'

and check the salt_minion service status:

# salt 'minion.intra.domain.org' cmd.run 'service salt_minion status'

SaltStack functions and modules

SaltStack comes with a vast library of functions available for execution. The functions which are available through the salt command are called Execution Modules.

Lots of execution modules exist, some are OS generic and even FreeBSD specific ones exist. These are really powerfull. Some examples are:

List the sysrc entries of your salt_minion

# salt 'minion.intra.somain.org' sysrc.get

Or check the packages on your salt_minion

# salt 'minion.intra.domain.org' pkg.audit

You can even update your FreeBSD OS:

# salt 'minion.intra.domain.org' freebsd-update.fetch
# salt 'minion.intra.domain.org' freebsd-update.install

And as a last example list the service enabled at boot on your salt_minion:

# salt 'minion.intra.domain.org' service.get_enabled'

Please read the documentation about execution modules to learn more about the possiblities. This is really powerfull, such that you can manage all your FreeBSD servers from your SaltStack master!

This completes this post in my SaltStack on FreeBSD series. More to come for sure!


Some (other) resources about this subject:

Updated: December 20, 2018