SaltStack Fundamentals

Get Started Tutorial


You'll learn how to:

  • Define a target to select one or more systems.
  • Use system data to define a target.
  • Use custom, user-defined data to define a target.

Estimated time: 10 minutes 


Targeting is how you select Salt minions when running commands, applying configurations, and when doing almost anything else in SaltStack that involves a Salt minion.

The simplest way to target is using the Salt minion ID. This value can be set to anything you want in the minion config file, and can be specified using the -i option in the bootstrap script.

salt 'minion1' disk.usage


Globbing on the Salt minion ID is supported by simply including a wildcard in the target:

salt 'minion*' disk.usage

So Many Ways to Target

In an ideal world, each system in your environment has a structured name that tells you everything you need to know about the hardware, OS, and system role. While we wait for that world, SaltStack provides a powerful targeting system to help you find and filter systems based on static and custom data.

Targets can be based on Salt minion system information using the Grains system:

salt -G 'os:Ubuntu'

Targets can be filtered by regular expression:

salt -E 'minion[0-9]'

Targets can be explicitly specified in a list:

salt -L 'minion1,minion2'

Or Multiple target types can be combined in one command:

salt -C 'G@os:Ubuntu and minion* or S@192.168.50.*'

Don’t worry too much about these targeting methods just yet. Just be confident that the targeting mechanism has enough flexibility to find the systems that you want to manage.

Got it, What’s Next?

Hopefully you’ve got a good understanding of how execution modules are used from the command line, and how to filter Salt minions using targets. The next step is to define re-usable configuration templates, called states, so we can make more awesomeness happen at once.