Chapter 3. Understanding the Salt CLI Syntax
It is very important to understand how Salt works when running commands from the CLI. The same methodologies can be used when instructing the system to execute commands periodically via Salt’s scheduler or when listening to events and via the reactor, only the syntax is different.
The Salt CLI syntax has the following pattern:
$sudo salt[<options>]<target> <function>[<arguments>]
One of the simplest uses is shown in Example 3-1, which executes the test.ping function on the device identified using the minion ID device1, without any options or arguments.
Example 3-1. Basic CLI execution invoking the test.ping execution function
$sudo salt device1 test.ping# output omitted
As we move forward, we’ll analyze each of the components shown here.
Functions and Arguments
Salt is structured as a very simple and pluggable core with many features able to interact between them. A very important functionlity is represented by the execution modules. They are the main entry point into the Salt world. The execution modules are Python modules, and are very easy to read (and eventually write) by anyone with basic Python programming knowledge. Everything is linear, which makes them flexible and easy to understand; in general, they consist only of simple functions.
In Example 3-1 we executed test.ping: test is the name of the execution module, while ping is the execution function inside this module.
Note
There are many module types in Salt and some ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access