Saltstack組態管理-業務引用haproxy

來源:互聯網
上載者:User

標籤:saltstack   haproxy

[[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             ==============================================>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                     =========>如果想要輪訓則改為roundrobin

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



[[email protected] cluster]# cat /srv/salt/prod/cluster/haproxy-outside.sls              =====================>業務引用haproxy的檔案

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-service的file狀態############# 

      - file: haproxy-service        ########監控haproxy-service的file狀態#############


haproxy項目中的top file檔案

[[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                       ###############進階狀態下執行檔案###########################


檢測是否成功:在瀏覽器輸入

http://10.0.0.7:8888/haproxy-status

http://10.0.0.8:8888/haproxy-status

使用者名稱:haproxy         密碼:saltstack

如果能顯示haproxy頁面即可


老男孩網址:http://www.etiantian.org

qq:406564728

歡迎交流

本文出自 “linux” 部落格,請務必保留此出處http://chenjisong.blog.51cto.com/7858025/1714333

Saltstack組態管理-業務引用haproxy

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.