Real-time management
The way of Cmd.run
Execute command
sudo salt ' * ' cmd.run ' uptime '
System module or custom module mode
For example, see Minion disk usage, using the usage function of the disk module
sudo salt ' * ' disk.usage
System self-built module reference Salt document http://docs.saltstack.com/en/latest/ref/modules/all/index.html
Use the Sys.doc module to query the related usage of the Salt module. Sys.doc equivalent to the system of man, can query the Salt module online doc
sudo salt ' * ' Sys.doc disk
Custom Modules
Customizing the module's directory/srv/salt/_modules/, the custom module path is typically/srv/salt/_modules/custom.py
Example
$cat/srv/salt/_modules/custom.py
def test ():
Return ' I am Test '
Manual Sync module to Minion
sudo salt ' * ' saltutil.sync_modules
Execution module
sudo salt ' * ' custom.test
States
State Module official Reference Document Http://docs.saltstack.com/ref/states/all/index.html
Used to implement state management for Minion, states define path/src/salt (file_roots variable definition in/etc/salt/master), states file using Yaml format definition
The suffix of the state file is SLS (Salt state), and the SLS file is written with the following following: Leave a space, or it will cause a parse error
To manually execute the state by modifying the admin account BASHRC for example
Prepare/src/salt/bashrc.sls for the following contents
/HOME/ADMIN/.BASHRC:
File.managed:
-SOURCE:SALT://FILES/BASHRC
-User:admin
-Group:admin
-mode:644
Prepare the bash file for distribution, SALT://FILES/BASHRC corresponds to/SRV/SALT/FILES/BASHRC
Make Bash.sls effective
sudo salt ' * ' State.sls ' BASHRC '
Highstate the way. is actually using TOP.SLS as the state's entry file
/src/salt/top.sls file as follows, Top.sls reference Bashrc.sls
Base
'*':
-BASHRC
Manual Execution Highstate Effective
sudo salt ' * ' state.highstate
Use schedule to get Minion to automate Highstate
Define/srv/pillar/top.sls
Base
'*':
-Schedule
Define/SRV/PILLAR/SCHEDULE.SLS (30-minute unit)
Schedule
Highstate:
Function:state.highstate
Minutes:30
Pillar
Official Documents Http://docs.saltstack.com/topics/tutorials/pillar.html
Pillar data definition path/srv/pillar, entry file:/srv/pillar/top.sls
View pillar Information
sudo salt ' * ' pillar.data
Grains
Official Documents Http://docs.saltstack.com/topics/targeting/grains.html
View Grains Categories
Salt ' * ' grains.ls
View all grains Information
Salt ' * ' Grains.items
View Grains a message
Salt ' * ' Grains.item osrelease
Common commands
See Minion on the report.
sudo salt-key
Master Sync Configuration
sudo salt ' * ' state.highstate