Saltstack Automating the deployment of Apache instances

Source: Internet
Author: User
Tags saltstack


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

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.