salt安装haproxy

发布时间:2020-10-13 21:51:05 作者:limingyu0312
来源:网络 阅读:259
###################初始化时定义好的包##########################################
include:
  - pkg.pkg-init

###################HAPROXY安装###########################################
haproxy-install:
  file.managed:
    - name: /usr/local/src/haproxy-1.7.2.tar.gz
    - source: salt://haproxy/files/haproxy-1.7.2.tar.gz
    - user: root
    - group: root
    - mode: 755
  cmd.run:
    - name: cd /usr/local/src/ && tar zxf haproxy-1.7.2.tar.gz && cd haproxy-1.7.2 && make TARGET=linux26 PREFIX=/usr/loc
al/haproxy && make install PREFIX=/usr/local/haproxy
    - unless: test -d /usr/local/haproxy
    - require:
      - pkg: pkg-init
      - file: haproxy-install


haproxy-init:
  file.managed:
    - name: /etc/init.d/haproxy
    - source: salt://haproxy/files/haproxy.init
    - user: root
    - group: root
    - mode: 755
    - require:
      - cmd: haproxy-install
  cmd.run:
    - name: chkconfig --add haproxy
    - unless: chkconfig --list |grep haproxy
    - require:
      - file: /etc/init.d/haproxy
      
      
net.ipv4.ip_nonlocal_bind:
  sysctl.present:
    - value: 1


haproxy-config-dir:
  file.directory:
    - name: /etc/haproxy
    - user: root
    - group: root
    - mode: 755



########################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
  cmd.run:
    - name: useradd -s /sbin/nologin haproxy
    - onlyif: id haproxy|echo $?
  service.running:
    - name: haproxy
    - enable: True
    - reload: True
    - require:
      - cmd: haproxy-init
    - watch:
      - file: haproxy-service


#########################top.sls###################################################


base:
  '*' :
    - init.env_init


prod:
  'web12.limingyu.com':
    - cluster.haproxy-outside
  'web13.limingyu.com':
    - cluster.haproxy-outside


推荐阅读:
  1. Centos如何安装部署salt yum?
  2. salt参数变更

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

source include files

上一篇:Docker实现Mariadb分库分表及读写分离功能

下一篇:浅谈React中组件间抽象

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》