4. Execute Commands
● salt ‘*’ cmd.run ‘ls -l /etc’
● salt ‘*’ disk.usage
● salt ‘*’ network.interfaces
5. Salt Command Syntax
Synopsis
salt <target> <module.function> <arguments>
Flags
-E
--pcre
Perl Compatible Reg. Exp. to match on minion name
-G
--grain
Allows targeting by matching predefined values in minion machines
-C
--compound
Allows combining criteria
6. Targeting
● salt ‘minion1’ disk.usage
● salt ‘minion*’ disk.usage
● salt -G ‘os:Ubuntu’ test.ping
● salt -E ‘minion[0-9]’ test.ping
● salt -C ‘G@os:Ubuntu and minion*’ test.ping
8. More definitions...
● Salt States - Scripts that use predefined functions that are run against minions
and tracked - preventing them from running
multiple times.
● Top File - Configures which files to run against which minions
9. Predefined Functions?!? I want to do more
Functions are just Python methods
sorted into modules. You can write your
own if you need to do anything too
complicated or you can be lazy:
https://github.com/saltstack-formulas
11. Pillar
Data assigned to minions using targets
Think configurations for a machine
i.e. Ports, Usernames, Passwords, etc.
Configure different machines to look at different
environments, hostnames, etc.
Applied by template or specified manually:
salt '*' state.apply ftpsync pillar='{"ftpusername": "test"}’
13. Ordering & Requisites
Things happen in order from the top file or based on includes…
To get fancy you can have the following:
14. Jinja - Magic Conditionals
Want to make Pillars more than statically assigned to minions?
Refresh the pillar variables and use them in a state file
16. 5 More Slides… Events
What kind of things can you get notified of
● Periodic Presence Updates - which minions are connected
● Minion Connected
● Minion Disconnnected
● State Completion
● Custom
○ Salt-call event.send /my/test/event ‘{“data”: “my test event”}’
17. Beacons
Trigger events for non-salt related things
● File System Changes
● System Load
● Service Status
● Shell Activity (user login)
● Network and Disk Usage
The 30 second summary
Salt is:
a configuration management system, capable of maintaining remote nodes in defined states (for example, ensuring that specific packages are installed and specific services are running)
a distributed remote execution system used to execute commands and query data on remote nodes, either individually or by arbitrary selection criteria
But who runs commands on all of their systems?
Tracks provisioned ‘version’ by knowing what states have been run on which minion by unique id