Salt Command

Salt commands have three main components: target, function, and arguments. The calls are constructed in this format:

salt 'target' <function> [arguments]

The target defines the client, or group of clients, on which to run the function.

The function is the particular task to be run.

Arguments provide any extra data required by the function.

1. Salt Targets

Salt command targets allow you to specify a client or group of clients. There are several different targets you can use.

General Targeting

List available grains on all clients:

salt '*'

Target a specific client:

salt ''
Glob Targeting

Target all clients using a particular domain:

salt '*'

Target all clients using a particular label:

salt 'label*'
List Targeting

Specify a flat list of clients, using their IDs:

salt -L 'client_ID1, client_ID2, client_ID3'
Regular Expression Targeting

You can also define targets with PCRE-compliant regular expressions:

salt -E '(?!web)'
IP Address Targeting

List available client IP addresses:

salt '*' network.ip_addrs

Target a specific client IP address:

salt -S ''

Target all clients on a subnet:

salt -S

2. Salt Execution Modules

When you have specified a target, provide the module and function to execute on the target.

Find which modules can be executed on the target:

salt '*' sys.doc

For a full list of callable modules, see

3. Salt Function Arguments

Functions accept arguments for any extra data.

For example, the pkg.install function requires an argument specifying which package to install:

salt '*' pkg.install yast2

You can provide more than one argument to a function, with spaces between them. For example:

salt '*' 'echo "Hello: $FIRST_NAME"' env='{FIRST_NAME: "John"}'