Last active
January 1, 2016 12:49
-
-
Save fsodogandji/8147615 to your computer and use it in GitHub Desktop.
salt tips & tricks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #run a test.ping on all minions: | |
| salt '*' test.ping | |
| # run a command on all minions: | |
| salt '*' cmd.run "service salt-minion restart" | |
| # run a command on a nodegroup calls warm_stdby: | |
| salt -N warm_stdby cmd.run "hostname" | |
| #list les id with x86_64 cpu | |
| salt -G 'cpuarch:x86_64' grains.item id | |
| #match minions with id master_1 or hot_stdby_1 | |
| salt -E 'master_1|hot_stdby_1' test.ping | |
| ## A combination of target definitions combined with boolean operators: | |
| salt -C 'webserv* and G@os:Debian or E@web-dc1-srv.*' test.ping | |
| #The previous command expressed in a top file | |
| base: | |
| 'webserv* and G@os:Debian or E@web-dc1-srv.*': | |
| - match: compound | |
| - webserver | |
| ##Match both web1-prod and web1-devel minions: | |
| salt -E 'web1-(prod|devel)' test.ping | |
| #the previous command in a top file | |
| base: | |
| 'web1-(prod|devel)': | |
| - match: pcre | |
| - webserver | |
| #execute a postgresql query | |
| salt '*' postgres.psql_query 'select * from pg_stat_activity' | |
| #execute top state file | |
| salt '*' state.highstate | |
| #execute only the my_state.sls script | |
| salt 'target' state.sls my_state | |
| #show all the highstate | |
| salt '*' state.show_highstate --out yaml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment