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.
Before you start
Before you create your targets, you must think about the target groups you want to create. For example, you might 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 new targets
Each target in Automation Config requires a name, Salt master, and target criteria. To define a new target including one or more minions:
- In the Targets workspace, click the Create button.
- Complete the form.
- In the Name field, enter a descriptive name for the new target.
- (Optional) Provide a description for the new target.
- 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 or 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.
- 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.
- When complete, click Save.
Your new target appears in the Targets workspace.
Assigning pillar to a target
To assign pillar to a target:
- In the Targets workspace, click the Menu next to the target you want to assign pillar data to.
- Click Attach pillar.
- In the Attach pillar 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.
- Click Update target.
Assigning a role to a target
To assign a role to a target:
- In the Targets workspace, click the Menu next to the target you want to assign roles to.
- Click Assign role.
- In the Assign role dialog, select the roles to assign.
For more information about user roles in Automation Config, see How do I define user roles.
- Click Update target.
The roles with resource permissions are added to the target group. You can see the new or updated roles in the Targets data grid.
Target settings
Targeting in Automation Config is similar to targeting in Open Salt, but Automation 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 the Salt Targeting Reference.
Each target in Automation Config includes a name, Salt master, and target criteria, as the following table shows.
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 Automation 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 targets by Salt master, click the radio button to 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 minions associated with the selected Salt master. |
Target criteria | Target 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, |
Glob | Wildcard match using the minion ID. For example, you might enter |
List | Specify a list of minions to include in the target. For example, 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 defintion. Automation Config does not allow you to add any other criteria in the target editor. |
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.