2 ms·
They recently rewrote the tutorial, which is available here: https://docs.saltstack.com/en/getstarted/ https://docs.saltstack.com/en/getstarted/ The easiest wa
by tapoxi 10y ago
They recently rewrote the tutorial, which is available here: https://docs.saltstack.com/en/getstarted/ https://docs.saltstack.com/en/getstarted/
The easiest way to learn Salt is by starting with execution modules (https://docs.saltstack.com/en/latest/ref/modules/all/index.html https://docs.saltstack.com/en/latest/ref/modules/all/index.h...), which are just Python modules that abstract the commands underneath and you can blast to machines, such as salt 'web~' pkg.install httpd to install Apache on all servers named web. You can send shell commands directly using cmd.run - salt 'web~' cmd.run 'yum -y install httpd'
(Note: I replaced asterisks with tildes in the above example due to HN formatting.)
On top of execution modules are state modules (https://docs.saltstack.com/en/latest/ref/states/all/ https://docs.saltstack.com/en/latest/ref/states/all/). You define a state in YAML and tell a host to execute the state with the state.apply execution module. States consist of an id (a unique string identifier), the state module to use, and arguments, like so:
base.packages.stable.install:
pkg.installed:
- pkgs:
- git
- zsh
- mosh
The other major components are runners (https://docs.saltstack.com/en/latest/ref/runners/ https://docs.saltstack.com/en/latest/ref/runners/), which are scripts written against the salt API that perform actions on the salt bus, and engines (https://docs.saltstack.com/en/latest/topics/engines/index.html https://docs.saltstack.com/en/latest/topics/engines/index.ht...), which are child processes spawned by the master that listen for and react to events - like the Slack bot I use. One of the included engines is called reactor, which makes it easy to script events in YAML.
There are more moving parts I'm not covering here, but I hope this helps you get started.