Saltstack Automated Transport Learning notes

Source: Internet
Author: User
Tags manual format definition parse error prepare disk usage saltstack


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.