1. State module
Description format: Yaml format, file with. SLS End
Understanding yamlhttps://www.unixhot.com/docs/saltstack/topics/yaml/index.html
Yaml Kick
First: Indent. Note that it must be two spaces. Indentation represents a hierarchical relationship.
Second: Colon. Combine with spaces to indicate indentation.
The second use of a colon is to represent a key-value pair
Third: The dash indicates the list. There are spaces behind the dash.
[email protected]/srv/hehe/salt/base]# cat Top.sls Base: ' * ':-init.initprod: ' linux-node* ':-cluster.haproxy- Outside-cluster.haproxy-outside-keepalived
2, the module writing storage location
Before writing the state module, define a salt environment; Edit the master configuration file
Vi/etc/salt/master, edit the master configuration file to find File_roots: The base environment that defines the salt. Note that after modifying the configuration file, be sure to restart Masterfile_roots:base:-/srv/salt/base prod:-/srv/salt/prod
3. Writing Apache.sls files
Storage Path/srv/salt/web
The file role is to follow Apache and start
Apache-install:pkg.installed:-Names:-httpd #要安装的包名-httpd-develapache-service:service. Running:-Name:httpd-enable:true #设置开机启动
4. Advanced State Module
# The State system uses a ' top ' file to tell the ' Minions what environment to# use and ' What ' modules to ' use. The state_top file is defined relative to the# root of the base environment as defined in "File Server settings" below.
Top.sls stored in the base environment
Base: ' linux-node1.example.com ': #minion id-web.apache ' linux-node2.example.com ':-Web.apache perform advanced state salt ' Linu X-node1.example.com ' State.highstate test=true
This article is from "Jacky Xin" blog, please be sure to keep this source http://jackyxin.blog.51cto.com/1976631/1834142
Saltstack State Management