All the following commands if run are run from the salt master.
Master accept minions
Once a minion is accepted you should refresh its package list
salt '*' pkg.refresh_db
Add a minion to a Grain/Role
Minion config file: C:\salt\conf\minion
Find the section that looks like the following and add your new role.
grains: roles: - IISStaging
That could become the following if we added a new role called PowerShellExample.
grains: roles: - IISStaging - PowerShellExample
After saving restart the salt minion with
- Open services.msc
- find salt-minion service
sudo salt-minion -d
Execute execution modules in state sls files
Target Machines based on Roles
Run command on all minions
salt '*' test.ping
Run command on only ubuntu servers
salt -C 'G@os:Ubuntu' test.ping
Run command on only IIS servers
salt -C 'G@roles:IISStaging' test.ping
Apply State to all servers
salt '*' state.highstate
Trigger run on all grains with the role NginxStaging Updates
salt -C 'G@roles:NginxStaging' state.highstate
Refresh Git WinRepo
salt-run winrepo.update_git_repos salt-run winrepo.genrepo salt '*' pkg.refresh_db
Debug High State Errors
Call the following from a minion
salt-call -l debug state.highstate
Upload states to master server in the folder
When uploading the files use an scp client (filezille, or whatever).
Upload the full contents of the local folder /salt/*.