[Email protected] ~]# mkdir/srv/salt/prod/cluster/files-p
[Email protected] ~]# Cd/srv/salt/prod/cluster/files
[[email protected] files]# ls
Haproxy-outside.cfg
[Email protected] files]# cat/srv/salt/prod/cluster/files/haproxy-outside.cfg ============================== Configuration file for ================>haproxy
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 =========> If you want to rotation then change to Roundrobin
Server Web-node1 10.0.0.7:8080 check inter rise 15 fall
Server Web-node2 10.0.0.8:8080 check inter rise 15 fall
[[email protected] cluster]# CAT/SRV/SALT/PROD/CLUSTER/HAPROXY-OUTSIDE.SLS =====================> Business Reference HAPR Oxy's File
Include
-Haproxy.install ################## #先包含安装 ####################
Haproxy-service: ##################### #申明id ######################
File.managed: ################### #文件管理模块及方法 #############
-Name:/etc/haproxy/haproxy.cfg ########## #指定haproxy的配置文件 ##############
-Source:salt://cluster/files/haproxy-outside.cfg # #salt中的配置文件 #########
-User:root
-Group:root
-mode:644
Service.running: ################ #模块和方法 ############
-Name:haproxy ################# #名称 #################
-Enable:true ############## #开机自动启动 ###########
-Reload:true ############## #是否允许重载 ###########
-Require:
-Cmd:haproxy-init ########## #依赖某个脚本 #############
-Watch: ####### #监控haproxy The file status of-service #############
-File:haproxy-service ####### #监控haproxy The file status of the-service #############
The top file file in the Haproxy project
[Email protected] files]# Cat/srv/salt/base/top.sls
Base
‘*‘:
-Init.env_init
Prod
' Linux-node1.example.com ':
-Cluster.haproxy-outside
' Linux-node2.example.com ':
-Cluster.haproxy-outside
[[email protected] files]# Salt ' * ' state.highstate ############## #高级状态下执行文件 ######################## ###
Detection success: in Browser input
Http://10.0.0.7:8888/haproxy-status
Http://10.0.0.8:8888/haproxy-status
User name: haproxy Password: saltstack
If you can display the Haproxy page
Old boy Website: http://www.etiantian.org
qq:406564728
Welcome to Exchange
This article is from the "Linux" blog, so be sure to keep this source http://chenjisong.blog.51cto.com/7858025/1714333
Saltstack Configuration Management-Business reference Haproxy