|
[root@linux-node1 files]# mkdir -p /srv/salt/prod/cluster/files
[root@linux-node1 files]# cd /srv/salt/prod/cluster/files/
[root@linux-node1 files]# vim haproxy-outside.cfg
global
maxconn 100000
chroot /usr/local/haproxy
uid 99
gid 99
daemon
nbproc 1
pidfile /usr/local/haproxy/logs/haproxy.pid
log 127.0.0.1 local3 info
defaults
option http-keep-alive
maxconn 100000
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
listen stats
mode http
bind 0.0.0.0:8888
stats enable
stats uri /haproxy-status
stats auth haproxy:saltstack
frontend frontend_www_example_com
bind 10.0.0.11:80
mode http
option httplog
log global
default_backend backend_www_example_com
backend backend_www_example_com
option forwardfor header X-REAL-IP
option httpchk HEAD / HTTP/1.0
balance source
server web-node1 10.0.0.7:8080 check inter 2000 rise 30 fall 15 #
server web-node2 10.0.0.8:8080 check inter 2000 rise 30 fall 15
[root@linux-node1 files]#cd ..
[root@linux-node1 cluster]# vim haproxy-outside.sls
include:
- haproxy.install
haproxy-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
[root@linux-node1 ~]# cd /srv/salt/base/
[root@linux-node1 base]# vim top.sls
base:
'*':
- init.env_init
prod:
'linux-node[1-2].example.com':
- cluster.haproxy-outside
[root@linux-node1 base]# salt '*' state.highstate
linux-node1.example.com:
----------
......
Summary
-------------
Succeeded: 21 (unchanged=2, changed=1)
Failed: 0
-------------
Total states run: 21
linux-node2.example.com:
----------
......
Summary
-------------
Succeeded: 21 (unchanged=9, changed=3)
Failed: 0
-------------
Total states run: 21 |
|
|
|
|
|
|