Managing systemd units with Salt
In many cases, you will want to manage your own systemd service definitions. Here's how.
In many cases, you will want to manage your own systemd service definitions. Here's how.
Writing Salt state files can be somewhat deceptive. They have a concept of includes, which allows you to split up state files and define dependencies, which can give you reduced duplication, a cleaner top.sls and a way to run state files individually without dropping all your requirements. However, unlike Python and other programming languages, the includes don't need (it's not even considered best practice) to be defined at the top of the file. Realizing this opens some opportunities.
Sometimes, you want to wait for a service to be running before running other states. Usually this can be done with a service.running
state, which is then required by other states. For example, a mysql_database.present
state can require the mysql service state, and it won't be ran before the mysql service has been started.
Targetting grains is probably the most widespread bad practice in Salt. It helps reduce verbosity and duplication in your top files, but also opens up some serious security holes in the event that a minion should be compromised.
SaltStack is an awesome provisioning tool I've been implementing in the past few months. I'd like to share a few pointers to other people working with it for the first time.