Saltstack Automatic Deployment haproxy+keepalived+nginx+memcache+php (fastcgi)

Source: Internet
Author: User
Tags haproxy saltstack

Series:

To deploy the Haproxy total directory structure

[[Email protected] srv]# tree salt/salt/├── base│   ├── init│    │   ├── audit.sls│   │   ├── dns.sls│    │   ├── env_init.sls│   │   ├──  epel.sls│   │   ├── files│   │   │    └── resolv.conf│   │   ├── history.sls│   │    └── sysctl.sls│   └── top.sls└── prod     ├── cluster    │   ├── files    │    │   ├── haproxy-outside.cfg    │   │    └── haproxy-outside.cfg.bak    │   └── haproxy-outside.sls     ├── haproxy    │   ├── files    │    │   ├── haproxy-1.4.24.tar.gz    │   │    └── haproxy.init    │   └── install.sls     ├── keepalived    │   └── files     └── pkg        └── pkg-init.sls


Multi-environment configuration of/etc/salt/master profiles on the 1.salt master server

File_roots:base:-/srv/salt/base prod:-/srv/salt/prod pillar_roots:base:-/srv/salt/pillar prod: -/srv/salt/pillar

2. Create a directory structure

[Email protected] srv]# pwd/srv[[email protected] srv]# tree. ├──pillar│├──base│└──prod└──salt├──base└ ──prod

3. Restart Salt-master

/etc/init.d/salt-master restart


4. System initialization

4.1.DNS Configuration

[Email protected] srv]# cat/srv/salt/base/init/dns.sls/etc/resolv.conf:file.managed:-source:salt://init/files/r esolv.conf-user:root-group:root-mode:644

4.2.History Recording Time

[Email protected] srv]# cat/srv/salt/base/init/history.sls/etc/profile:file.managed:-Text:-Export Histtim eformat= "%F%T (' WhoAmI ')"

4.3. Command operation Audit

[Email protected] srv]# cat/srv/salt/base/init/audit.sls/etc/bashrc:file.append:-Text:-Export Prompt_comm And= ' {msg=$ (History 1 | {read x y; echo $y;}); Logger "[euid=$ (WhoAmI)]": $ (Who am I): [' pwd '] "$msg"; }‘

4.4.epel Warehouse

[Email protected] srv]# Cat/srv/salt/base/init/epel.sls yum_rep_release:pkg.installed:-Sources:-Epel-relea Se:http://mirrors.aliyun.com/epel/6/x86_64/epel-release-6-8.noarch.rpm-unless:rpm-qa|grep epel-release-6-8

4.5. Initializing the Environment reference

[Email protected] srv]# Cat/srv/salt/base/init/env_init.sls include:-Init.dns-init.history-init.audit


5.Haproxy Configuration Management

5.1.PKG module for installing source code compilation Dependency Package

[Email protected] prod]# Cat/srv/salt/prod/pkg/pkg-init.sls pkg-init:pkg.installed:-Names:-gcc-gcc- C + +-Glibc-make-autoconf-openssl-openssl-devel

5.2.Haproxy Service Configuration

CD/USR/LOCAL/SRC/CP Haproxy-1.4.24.tar.gz/srv/salt/prod/haproxy/filestar XF Haproxy-1.4.24.tar.gzcd/usr/local/src /haproxy-1.4.24/examples/sed-i ' s/\/usr\/sbin\/' \ $BASENAME '/\/usr\/local\/haproxy\/sbin\/' \ $BASENAME '/g ' Haproxy.initcp Haproxy.init/srv/salt/prod/haproxy/files

5.3. Write Haproxy Install SLS

[Email protected] haproxy]# Cat/srv/salt/prod/haproxy/install.sls include:-Pkg.pkg-init
haproxy-install:  file.managed:    -  name: /usr/local/src/haproxy-1.4.24.tar.gz    - source: salt:// haproxy/files/haproxy-1.4.24.tar.gz    - mode: 755    -  user: root    - group: root  cmd.run:     - name: cd /usr/local/src && tar xf haproxy-1.4.24.tar.gz  && cd haproxy-1.4.24 && make target=linux26 prefix=/usr/ local/haproxy && make install prefix=/usr/local/haproxy    -  unless: test -d /usr/local/haproxy    - require:       - pkg: pkg-init      - file:  Haproxy-install/etc/init.d/haproxy: 
file.managed:    - source: salt://haproxy/ Files/haproxy.init    - mode: 755    - user: root     - group: root    - require:       - cmd: haproxy-installhaproxy-config-dir:    file.directory:     - name: /etc/haproxy    - mode: 755     - user: root    - group: roothaproxy-init:   cmd.run:    - name: chkconfig --add haproxy    -  unless: chkconfig --list|grep  haproxy    - require:       - file: /etc/init.d/haproxy 

5.4.Haproxy Business Applications

[Email protected] haproxy]# Cat/srv/salt/prod/cluster/haproxy-outside.sls include:-Haproxy.installhaproxy-service     : file.managed:-Name:/etc/haproxy/haproxy.cfg-source:salt://cluster/files/haproxy-outside.cfg-user:root      -group:root-mode:644 service.running:-Name:haproxy-enable:true-reload:true-require: -Cmd:haproxy-init-watch:-File:haproxy-service
[[Email protected] haproxy]# cat /srv/salt/prod/cluster/files/haproxy-outside.cfgglobal          log 127.0.0.1:514 local0 warning          chroot /usr/local/haproxy                 group haproxy                        user haproxy                        daemon                               nbproc 8                            pidfile  /usr/local/haproxy/logs/haproxy.pid            maxconn 20000                          spread-checks 3
defaults         log global                              mode http          #option  httplog                          #option  httpclose                        #option   dontlognull                      #option  forwardfor                      option redispatch                       #option  abortonclose                    retries  3                               #balance  roundrobin                     # balance source                          #balance  leastconn                      contimeout  5000                        clitimeout 50000                       srvtimeout 50000                          #timeout  check 2000

                    

listen randolph_status                             bind *:80          mode http                         stats  Enable             stats uri /admin ?status                #stats   realm haproxty\ haproxy         stats auth  salt:randolph              #stats  auth  admin1:admin1              stats  hide-version                      #stats  admin if TRUE                     #listen   webserver           #option  httpchk HEAD /checkstatus.html HTTP/1.0            option httpclose          option forwardfor         balance  roundrobin        cookie serverid insert indirect          timeout server  15s          timeout connect 15s          server web01 192.168.21.161:8082  check port 80 inter 5000 fall 5          server web02 192.168.21.163:8082  check port 80  inter 5000 fall 5

5.5. Write Haproxy Install SLS

[Email protected] haproxy]# Cat/srv/salt/prod/cluster/haproxy-outside.sls include:-Haproxy.installhaproxy-service     : file.managed:-Name:/etc/haproxy/haproxy.cfg-source:salt://cluster/files/haproxy-outside.cfg-user:root      -group:root-mode:644 service.running:-Name:haproxy-enable:true-reload:true-require: -Cmd:haproxy-init-watch:-File:haproxy-service

6. Perform haproxy status

[email protected] base]# cat Top.sls base:jenkins.saltstack.me:-init.env_initprod:jenkins.saltstack.me:-CLU Ster.haproxy-outside

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/8F/63/wKioL1jcxmjhUAWeAAA0aL4HC2Y251.png "title=" Haproxy.png "alt=" Wkiol1jcxmjhuaweaaa0al4hc2y251.png "/>


Keep updating ...


This article is from the "Randolph" blog, make sure to keep this source http://randolph.blog.51cto.com/10900500/1911816

Saltstack Automatic Deployment haproxy+keepalived+nginx+memcache+php (fastcgi)

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.