We use this module to get server grains from salt API so we can use it in UnusedServers PowerShell module.
- Determine PowerShell modules directory you want to use (type
$env:PSModulePathand chose one, for examplec:\Windows\system32\WindowsPowerShell\v1.0\Modules). - Download repo and place all files under Modules directory you chose in the first step into
Spot-Saltfolder (c:\Windows\system32\WindowsPowerShell\v1.0\Modules\Spot-Salt). - Make sure the files are not blocked. Right click on the files and un-block them by going into properties.
- Make sure to set your PowerShell Execution Policy to
RemoteSigned, for exampleSet-ExecutionPolicy RemoteSigned -Force. - Type
Get-Module -ListAvailableand make sure you see Spot-Salt module in the list
help Salt-Connect -Detailed
help Salt -Detailed
help salt-Run -Detailed
salt-Connect saltStaging: connects to saltStaging salt master and obtains security token
salt "TEST*" cmd.run "ifconfig": runs ifconfig on TEST server. This will return JID number that you can use with salt-Run command
salt-Run 20151001150618354722: will return result for job ID 20151001150618354722 as an object.
salt "TEST*" cmd.run "ifconfig" | salt-run -Loud: will return results of the command to the console in a nice format
salt -E "TEST0(1|2|3)" grains.items | salt-run: will return all grains for three servers TEST01, TEST02, TEST03 as an object so it is easy to consume it in another scipt