1, configure the Pillar Top.sls:
Base
Nova
-Match:nodegroup
-Nova
Neutron
-Match:nodegroup
-Neutron
2. Configuration of pillar Nova and neutron:
Apache:
Name:httpd
ip:172.16.171.120
Root:/var/www/neutron
Apache:
Name:httpd
ip:172.16.171.110
Root:/var/www/nova
3, configure the state of the TOP.SLS:
Base
‘*‘:
-Apache.start
-Apache.stop
4, Configuration Apache.start:
Apache.start:
Pkg.installed:
-Name: {{pillar[' Apache ' [' Name ']}}
Service.running:
-Name: {{pillar[' Apache ' [' Name ']}}
-Watch:
-Pkg: {{pillar[' Apache ' [' Name ']}}
-File:/etc/httpd/conf/httpd.conf
-User:apache
User.present:
-Name:apache
-Shell:/sbin/nologin
-Home: {{pillar[' Apache ' [' Root ']}}
-Require:
-Group:apache
Group.present:
-Name:apache
-Require:
-Pkg: {{pillar[' Apache ' [' Name ']}}
File.managed:
-Name:/etc/httpd/conf/httpd.conf
-Source:salt://apache/httpd.conf
-User:root
-Group:root
-mode:644
-Template:jinjaNote: You must specify, otherwise the pillar variable in the httpd.conf cannot be replaced.
{{pillar[' Apache ' [' Root ']}}/new:
File.directory:
-file_mode:640
-dir_mode:750
{{pillar[' Apache ' [' Root ']}}/test/process.sh:
File.managed:
-source:salt://apache/process.sh
-Makedirs:true
4, Configuration apache.stop:
Apache.stop:
Pkg.removed:
-Name: {{pillar[' Apache ' [' Name ']}}
-Require:
-Service: {{pillar[' Apache ' [' Name ']}}
Service.dead:
-Name: {{pillar[' Apache ' [' Name ']}}
User.absent:
-Name:apache
-Purge:true
-Require:
-Pkg: {{pillar[' Apache ' [' Name ']}}
5. Specify in the httpd.conf configuration file:
Listen {{pillar[' Apache '] [' IP ']}}:80
DocumentRoot {{pillar[' Apache ' [' Root ']}}
6. If you do not specify the pillar variable in httpd.conf, specify the custom variable name directly, as follows:
Listen {{addr}}:80
DocumentRoot {{dir}}
7, you can specify defaults or context in Apache.start, as follows:
Apache.start:
Pkg.installed:
-Name: {{pillar[' Apache ' [' Name ']}}
Service.running:
-Name: {{pillar[' Apache ' [' Name ']}}
-Watch:
-Pkg: {{pillar[' Apache ' [' Name ']}}
-File:/etc/httpd/conf/httpd.conf
-User:apache
User.present:
-Name:apache
-Shell:/sbin/nologin
-Home: {{pillar[' Apache ' [' Root ']}}
-Require:
-Group:apache
Group.present:
-Name:apache
-Require:
-Pkg: {{pillar[' Apache ' [' Name ']}}
File.managed:
-Name:/etc/httpd/conf/httpd.conf
-Source:salt://apache/httpd.conf
-User:root
-Group:root
-mode:644
-Template:jinja
-Context:
Addr: {{pillar[' Apache ' [' IP ']}}
Dir: {{pillar[' Apache ' [' Root ']}}
This article is from the "Autumn Fairy tale" blog, please be sure to keep this source http://wushank.blog.51cto.com/3489095/1680918
Saltstack Automating the deployment of Apache instances