Difficulty: Beginner
Estimated Time: 10 minutes

Targeting

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. In this tutorial, we're going to cover the basics of how to target your minions to have them do your bidding.

Scope

In this tutorial, you will 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.

Environment

To prevent you from having to set up the prerequisites to learning, we've taken the liberty of pre-installing and configuring a basic Master-Minion configuration. You will be running the commands in this tutorial in the following environment:

Hostname Operating System Salt Role Salt Version
salt-master Ubuntu 16.04.5 LTS (Xenial Xerus) Master 2019.2.0 (Fluorine)
salt-minion1 Ubuntu 16.04.5 LTS (Xenial Xerus) Minion 2019.2.0 (Fluorine)

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.

Targeting

Step 1 of 4

Targeting with the Minion ID

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

In this scenario, we've already installed and configured a minion on an Ubuntu machine with a minion ID of salt-minion. Once you know the ID, you can then target that minion and do things like run commands against it. For example, we could reach out to the minion to find some statistics on how the disk usage is looking by running salt 'salt-minion' disk.usage.