pkg-init:
pkg.installed:
- names:
- gcc
- gcc-c++
haproxy-install:
file.managed:
- name: /usr/local/src/haproxy-1.7.9.tar.gz
- source: salt://install/files/haproxy-1.7.9.tar.gz
- mode: 755
- user: root
- group: root
cmd.run:
- name: cd /usr/local/src && tar zxf haproxy-1.7.9.tar.gz && cd haproxy-1.7.9 && make TARGET=linux2628 PREFIX=/usr/local/haproxy && make install PREFIX=/usr/local/haproxy && mkdir /etc/haproxy && useradd haproxy -s /sbin/nologin
- unless : test -d /usr/local/haproxy
- require:
- pkg: pkg-init
- file: haproxy-install
/etc/init.d/haproxy:
file.managed:
- source: salt://install/files/haproxy.init
- user: root
- group: root
- mode: 755
- require:
- cmd: haproxy-install
haproxy-init:
cmd.run:
- name: chkconfig --add haproxy
- unless: chkconfig --list | grep haproxy
- require:
- file: /etc/init.d/haproxy
haproxy-config:
file.managed:
- name: /etc/haproxy/haproxy.cfg
- source: salt://install/files/haproxy.cfg
- user: root
- group: root
- mode: 755
- template: jinja
- defaults:
IPADDR: {{ grains['fqdn_ip4'][0] }}
haproxy-service:
service.running:
- name: haproxy
- enable: True
- reload: True
- require:
- cmd: haproxy-init
- watch:
- file: haproxy-config