Scenario: The company has 10 servers need to install lamp test environment, using Saltstack to write state files for batch deployment, can improve work efficiency, reduce the possibility of human error, to ensure the consistency of the environment.
Saltstack's configuration Management lamp actual case:
1. Modify the master configuration file to specify the dev environment.
4 ^file/etc/salt/master file_roots: base: -/srv/salt/base Dev: -/srv/salt/dev
2. Write the state file, and the final directory tree looks like this:
[Email protected] dev]# tree /srv/salt/dev//srv/salt/dev/├──files│├──httpd.conf│└──my.cnf├──lamp.sls└── Top.sls14 files
The detailed contents of the 3.state file are as follows:
[email protected] dev]# cat Top.sls--can also be found here in/srv/salt/base/ Top.sls is defined in the Unified portal file. Dev:'node2.xkops.com': -Lamp[[email protected] dev]# cat Lamp.sls lamp-pkg-install:pkg.installed:-names:-MySQL-PHP-php-MySQL-php-PDO-php-CLI-php-commonhttpd-service:pkg.installed:-names:-httpd file.managed:-Name:/etc/httpd/conf/httpd.conf-Source:salt://files/httpd.conf-User:root-Group:root-Mode:644-require:-pkg:httpd-Service service.running:-name:httpd-Enable:true-Reload:true-Watch:-file:httpd-Servicemysql-service:pkg.installed:-name:mysql-Server file.managed:-Name:/etc/my.cnf-Source:salt://files/my.cnf-User:root-Group:root-Mode:644-require:-pkg:mysql-Service service.running:-Name:mysqld-Enable:true-Watch:-File:mysql-service
4. Perform the configuration management state file on the master side of the Node1. (Recommended test first, then formally executed)
[[email protected] dev]# Salt ' * ' state.highstate env=dev test
[[email protected] dev]# Salt ' * ' state.highstate Env=dev
Saltstack (eight) configuration management deployment Lamp