The top file manages SLS state files for salt minions. It would be analogous to the puppet manifest site.pp, but is written in YAML which keeps things minimal and clean. Things are pretty well documented on saltstack.com but we can go over the basics to get you up and running.
If we don’t edit the configuration file /etc/salt/master, the default path for the top file and other SLS files is /srv/salt. You can change this in /etc/salt/master, looking for the following option:
For an example, lets create a simple top.sls to include an sls called cron to be included for all minions, and another named apache to only match minions with a hostname starting with web (web01.example.com, web02.example.com, etc.)
Note: These sls files do not yet exist, so a run with just this file will fail and tell you it can’t fine anything named cron or apache.
Now lets create these simple state files, later we’ll move them into their own directories and serve files from them.
- name: httpd
- name: httpd
This command runs top file locally on your server which is useful for debugging and can be run from any minion:
This command from the salt master runs the top file across all minions.
salt '*' state.highstate
Test apache.sls from any minion.
salt-call state.sls apache
Run this from the master to push to all minions:
salt '*' state.sls apache
Run this from the master to push apache to all servers with an fqdn beginning with web.
salt 'web*' state.sls apacheComments)