Defining targets for your jobs or operations helps to prevent operations from running on nodes that should not run that operation. You can organize your targets using grains, globs, lists, or compounds.

What is a target?

A target is a group of minions, across one or many Salt masters, that a job's Salt command applies to. Targets can contain minions that are connected to any Salt master in your environment. A Salt master can also be managed like a minion and can be a target if it is running the minion service.

You can create targets for your jobs in the Minions workspace. By default, when you open the workspace, the All Minions target is active. The All Minions target lists all the minions you have permission to access.

Before you start

Before you create your targets, you must think about the target groups you want to create. For example, you may want to create a target group for a security zone or a single subnet. How you organize your target groups will depend on your organization's needs.

Creating a new target

Each target in SaltStack Config requires a name, Salt master, and target criteria. To define a new target including one or more minions:

  1. In the minions workspace, click All Minions in the Targets side panel.
  2. Click the Create target button.
  3. In the Create target dialog in the Name field, enter a descriptive name for the new target.
  4. By default, the All masters setting is enabled, which means that minions being managed by any Salt master can be included in the target. Click this button to apply this target only to a subset of minions associated with one of more Salt masters.

    If you disable this setting, a menu appears that you can use to select which Salt master or Salt masters to apply the target to. See Target settings for more information.

  5. Click the Grain menu and select the type of target you want to use. You can target minions using grains, globs, lists, or compounds. See Target settings for more information about these targeting options. For more general background information about Salt targets, see Targeting minions.
  6. Different target settings and criteria are available based on the type of target you selected in the previous step. For more information about these settings, see Target settings.
    Note: If you select Compound as the first criterion, you must follow the targeting syntax included in the Salt Targeting Reference, and you must include any secondary criteria in the compound target definition. SaltStack Config does not allow you to add any other criteria in the target editor. For more on compound targeting, see Target settings.
  7. When complete, click Save.

Your new target appears in the list of targets in the Minions workspace.

Creating a simple list target

To create a new target using a simple list:
  1. In the Minions workspace, click All Minions in the Targets side panel.
  2. Click the checkbox next to the minions you want to include in the list and click Create target.
    Note: Filtering or sorting your minions can be useful for defining a list.

    The selected list is included as a criterion.

  3. Enter a target name and define any additional target settings. See Target settings.
  4. When complete, click Save.

Assigning pillar to a target

Pillars are primarily used to store secrets or other highly sensitive data, such as account credentials, cryptographic keys, or passwords. Pillars are also useful for storing non-secret data that you don’t want to place directly in your state files, such as configuration data. To assign pillar data to a specific target of minions:
  1. In the Minions workspace, select a target from the Targets side panel.
  2. Click More actions.
  3. In the menu, click Attach Pillar.
  4. In the dialog, select the pillars you want to apply to the target.

    In addition to selecting a pillar, select Refresh pillar to make the pillar available to the selected target immediately.

  5. Click Update target.
    The selected pillar data is now available to all minions in the target.
    Note: You can also assign a pillar to a target in the Pillars workspace. For more information, see How do I create state files and pillar data.

Target settings

Targeting in SaltStack Config is similar to targeting in Open Source Salt, but SaltStack Config has a simplified interface for defining targets, which also enables you to save target definitions for reuse. For more on targeting in Salt, see Salt Targeting Reference.

Each target in SaltStack Config includes a name, Salt master, and target criteria, described in detail below.

Setting Description
Name

Enter a target name. Target names do not have to be unique. This might result in different items displaying with the same name in the SaltStack Config user interface.

All Salt masters

By default, the target includes all Salt masters. However, you can choose to target minions that only belong to a specific Salt master.

For example, if your environment has several nodes responsible for running a particular application, and you have partitioned your Salt infrastructure so these machines are all connected to a single Salt master, you might create a target that includes the entire subset of minions by selecting only the Salt master.

To enable target by Salt master, click the radio button o deactivate this setting. A new group of settings appears.

Under the Master field, select a Salt master whose minions you want to target. All additional target criteria are applied only to the subset of inions associated with the selected Salt master.

Target criteria

Targets are dynamic, and new minions are automatically added to any matching target definition. If you don't want to include new minions that could match the dynamic target in the future, save your target as a list instead.

You can use target criteria to specify a group of minions, referring to the following field descriptions.

Target type Description
Grain

Match a specific grain value, for example, osfullname is Debian. Once you select a grain, the value list pre-populates so you can click the field to view available options, or start typing.

When creating compound targets using grains, RaaS returns no minions if the grain name has a space in the name. For this reason, any space is automatically converted to a ? instead.

Glob Wildcard match using the minion ID. For example, you might enter webserver* to select multiple minions, named webserver01, webserver02, and webserver03.
List

Specify a list of minions to include in the target. For example, dc3-north-db1,dc3-north-db2.

Specifying a list is useful if you do not want to grant access to targets dynamically. This prevents new minions that match the dynamic target criteria from being added to a target automatically.

Compound

Combine multiple target interfaces, separated by conjunctions and, or, and not.

If you select Compound as the first criterion, you must follow the targeting syntax included in the Salt Targeting Reference, and you must include any secondary criteria in the compound target definition. SaltStack Config does not allow you to add any other criteria in the target editor. For more on compound targeting, see Target settings.

Best practices for creating targets

Create simple target rules

Although there's no limit to how many targets you can create in SaltStack Config, try to create the simplest targeting rules that encompass all the machines you need to take action against.

Identify required use cases

Before you create targets for your jobs, start with a list of use cases to help you determine which target types to use. For example, for patching, you can use grains to target a specific operating system. The following table contains some examples of target groups, common use cases, and recommended target type.
Target group Use case Target type
Operating system
  • Patching
  • Discovery or diagnostics
  • Standards compliance
Grain
Application cluster
  • Application installation
  • Directed compliance
  • Selective patching
  • Configuration management and drift detection or remediation
Glob or list
Data center, subnet, availability zone, or other network segment
  • Compliance
  • Network or regional configuration
Glob or custom grain
Custom method
  • Approved or banned packages
  • User management based on presence or absence of installed applications
  • User accounts
Custom grain

Next steps

After you create the targets you need, you can create jobs that will run tasks and processes against the targeted minions. See How do I create jobs for more information.