当前位置:网站首页>Saltstack state state file configuration instance
Saltstack state state file configuration instance
2022-06-24 19:24:00 【51CTO】
Brief introduction
What is? state modular ?
- Remote execution is salt At the heart of .
- Administrators can execute modules remotely by executing , Reach the right minion The control of ( Such as cmd.run “yum install -y httpd”). But for the minion Environmental or state control , That is, you want minion What kind of state have you reached , use state Modules are more convenient . Just describe what you want salt minion What state can be reached , The executive part consists of state Module to complete .
Remote execution &&State modular :
- difference : The execution module is procedural , Successive calls will execute the same logic and instructions ; The status module is descriptive , They just do the necessary work , stay minion The specified state is reached according to the description file .
- be-all state Modules will follow this principle , The function is performed only when it is detected that the real state is different from the desired state . This can be done by judgment minion Enter the specified state with minimum cost .
State The configuration file (sls)
SLS Configuration file usage YAML Language description .Salt default sls Of documents renderer yes YAML renderer, Its job is to YAML The structure of the data format is compiled into Python Data structure to Salt Use .
Three important rules :
- Indent : Use two spaces , Do not use tab key .
- The colon : And Python The mapping of is as follows :
- The short bar : Use a short bar and a space to represent the list item (Python List in [])
State File format :
State sls In profile :
- <ID Declaration> Must be unique and effective Python character string , Self defined .
- <State Module>.<Function> The same format as the remote execution command , However, the specific supported modules and functions are different from those executed remotely , Can be passed separately sys.list_state_modules、sys.list_state_functions see , The remote counterpart is sys.list_modules、sys.list_functions.
- Finally, the function parameters , The first function argument is usually name, Then there are the other parameters required for the State . Please refer to sys.state_doc.
Practical cases
- To configure windows A firewall
conf-firewall.sls
Practice effect :
Before execution , Private network and public network firewalls are on ;state After execution , Become closed .
- management windows service
conf-services.sls
Practice effect :
Before execution :

After execution : Both services are stopped , And w32Time It is set to start automatically .

- perform ps Script 【 Take server blocking as an example 】
conf-gateway.sls
Before execution :

After execution : The default gateway is deleted .

- Enable RDP Remote desktop
conf-rdp.sls
Practice effect :

边栏推荐
- The group offsets of the Kafka of the Flink SQL. If the specified groupid is not mentioned
- Power supply noise analysis
- Fabric ledger data block structure analysis (I): how to analyze the smart contract transaction data in the ledger
- 制造业项目MDM主数据项目实施心得
- Will the CDC read out of order when I use SQL
- 8 challenges of BSS application cloud native deployment
- subject may not be empty [subject-empty]
- Starring V6 platform development take out point process
- 一次 MySQL 误操作导致的事故,高可用都不顶不住!
- Preliminary study nuxt3
猜你喜欢

Set up your own website (8)

Experience of MDM master data project implementation for manufacturing projects

数字孪生行业案例:智慧港口数字化

Volcano becomes spark default batch scheduler

Introduction and download of nine npp\gpp datasets

Freeswitch uses origin to dialplan

Interpreting harmonyos application and service ecology

一文详解|Go 分布式链路追踪实现原理

Vs2017 setting function Chinese Notes

How to customize cursor position in wechat applet rotation chart
随机推荐
cdc+mysql connector从维表中join的日期时间字段会被+8:00,请问阿里云托管的
Does finkcdc support sqlserver2008?
企业网络管理员必备的故障处理系统
Server lease error in Hong Kong may lead to serious consequences
Intel and Microsoft give full play to the potential energy of edge cloud collaboration to promote the large-scale deployment of AI
NFT质押流动性挖矿系统开发技术
How to use R package ggtreeextra to draw evolution tree
Power efficiency test
If the programmer tells the truth during the interview
一文理解OpenStack网络
Based on STM32F103 0.96 inch OLED LCD driver (IIC communication)
Make track map
cdc sql表里面的datetime要用什么类型替换
MySQL binlog data source configuration document, please share
Necessary fault handling system for enterprise network administrator
Multi cloud mode is not a "master key"
小滴课堂海量数据处理商用短链平台大课
three. Basic framework created by JS
Geoscience remote sensing data collection online
Xiaobai, let me ask you guys, is MySQL binlog extracted by CDC in strict order