Saltstack (vii) Configuration management system initialization init

Source: Internet
Author: User
Tags saltstack

Saltstack Configuration Management sub-environment management:
①.base is a basic environment that typically stores configuration management information that is used by all servers.
②.dev for developing test environments, it is common to store configuration management information that is used by the development test server.
③.pro is an online environment that typically stores configuration management information used by online servers.
The state file entry for Saltstack configuration management is Top.sls, and it is recommended that you configure one Top.sls file per environment.

Saltstack System Initialization Practical case:
1. Modify the master configuration file on the Node1 to define the base environment.

Base 2 ^file_roots/etc/salt/master file_roots:  base:    -/srv/salt/Base 

2. Write the state file, and the final directory tree looks like this:

Base]   # tree/srv/salt/Base//srv/salt/base/├──init│├──dns.sls│├──env_init.sls│├──files││ ├──hosts││└──zabbix_agentd.conf│├──history.sls│├──sysctl.sls│└──zabbix_agent.sls└──top.sls2  8 files

Details of the 3.state file:
* Note: Because of too many configuration files, the direct definition in the Top.sls file is too bloated, so defined a Env_init.sls file, all the state files include, see the last file content.

[[Email protected]Base]# Cat Top.slsBase:  '*':    -Init.env_init[[email protected]Base]# Cat init/Dns.sls DNS-service:file.managed:-Name:/etc/hosts-Source:salt://init/files/hosts-User:root-Group:root-Mode:644[[Email protected]Base]# Cat init/History.sls/etc/Profile:file.append:-Text:-Export histtimeformat="%F%T ' WhoAmI '"[[Email protected]Base]# Cat init/Sysctl.sls net.ipv4.ip_forward:sysctl.present:-Value:1vm.swappiness:sysctl.present:-Value:1[[Email protected]Base]# Cat init/Zabbix_agent.sls Zabbix-agent:pkg.installed:-name:zabbix-Agent file.managed:-Name:/etc/zabbix/zabbix_agentd.conf-Source:salt://init/files/zabbix_agentd.conf-User:root-Group:root-Mode:644-Template:jinja-Defaults:host:192.168.3.1    ----Here to remember to configure the template file {{HOST}}, if you do not remember to use the method, refer to the Configuration Management State article. -require:-pkg:zabbix-Agent service.running:-name:zabbix-Agent-Enable:true-Watch:-file:zabbix-Agent [[email protected]Base]# Cat init/Env_init.sls include:-Init.dns-Init.sysctl-init.history-Init.zabbix_agent

4. The state file for configuration management is executed on the master side of the Node1, which can be executed before the test is passed.

[[email protected] ~]# Salt ' * ' state.highstate env=base Test ---Add the test parameter, the simulation performs the operation, does not actually execute.
[[email protected] ~]# Salt ' * ' state.highstate env=base

Saltstack (vii) Configuration management system initialization init

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.