If I have to execute the following 3 commands, how do I group them so I only have to call one?
salt '*' git.fetch cwd=/var/git/myproject opts='--all' user=git
salt '*' git.pull cwd=/var/git/myproject opts='origin master'
salt '*' nginx.signal reload
I can use fabric to put those in a single function say deploy
which might accept a minion name then run through master, but I'm wondering if saltstack has something built-in?
This is a good candidate for a custom module.
You can read about creating custom modules here: http://docs.saltstack.com/ref/modules/index.html. Place your custom module in /srv/salt/_modules (the default location) and then run
salt \* saltutil.sync_modules
Your module will then be available to run on your minions.
If your module is named 'deploy' and the function is 'mysite', then your custom command will look like this:
salt \* deploy.mysite
If you want to target a specific minion then it will look like this:
salt 'minion_name' deploy.mysite
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With