当前位置:网站首页>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 :
边栏推荐
- At present, only CDC monitors Mysql to get the data of new columns. Sqlserver can't, can it
- 使用阿里云RDS for SQL Server性能洞察优化数据库负载-初识性能洞察
- Starring V6 platform development take out point process
- 应用实践 | 海量数据,秒级分析!Flink+Doris 构建实时数仓方案
- Unityshader world coordinates do not change with the model
- Multi segment curve temperature control FB (SCL program) of PLC function block series
- Why useevent is not good enough
- Xiaobai, let me ask you guys, is MySQL binlog extracted by CDC in strict order
- 想问下 pgsql cdc 账号同一个 多个 task 会有影响吗,我现在3个task 只有一个 有
- Introduction to alos satellite
猜你喜欢
Unity移动端游戏性能优化简谱之 以引擎模块为划分的CPU耗时调优
Introduction to alos satellite
Sr-gnn shift robot gnns: overlapping the limitations of localized graph training data
Game between apifox and other interface development tools
論文解讀(SR-GNN)《Shift-Robust GNNs: Overcoming the Limitations of Localized Graph Training Data》
60 个神级 VS Code 插件!!
starring V6平台开发接出点流程
How to customize cursor position in wechat applet rotation chart
Download steps of STM32 firmware library
High dimension low code: component rendering sub component
随机推荐
NFT双币质押流动性挖矿系统开发
thinkphp6中怎么使用jwt认证
应用实践 | 海量数据,秒级分析!Flink+Doris 构建实时数仓方案
小滴课堂海量数据处理商用短链平台大课
Make track map
Interpreting harmonyos application and service ecology
System design idea of time traceability
Vs2017 add header file path method
Application DDoS attack principle and defense method
Obstacle avoidance sensor module (stm32f103c8t6)
The script implements the automated deployment of raid0
Geoscience remote sensing data collection online
Source code analysis of ArrayList
Technology implementation | Apache Doris cold and hot data storage (I)
Game between apifox and other interface development tools
Unity移动端游戏性能优化简谱之 以引擎模块为划分的CPU耗时调优
A detailed explanation of the implementation principle of go Distributed Link Tracking
8 challenges of BSS application cloud native deployment
finkcdc支持sqlserver2008么?
What other data besides SHP data