Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saltstack grouping commands

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?

like image 246
Marconi Avatar asked Feb 23 '13 12:02

Marconi


1 Answers

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
like image 118
Utah_Dave Avatar answered Oct 11 '22 23:10

Utah_Dave