2020-01-12 13:50:03 +01:00
|
|
|
---
|
|
|
|
- name: Prepare
|
2020-01-14 18:07:32 +01:00
|
|
|
hosts: loadbalancer
|
2020-01-12 13:50:03 +01:00
|
|
|
tasks:
|
2020-02-22 15:33:12 +01:00
|
|
|
- name: Ensure apt cache is updated
|
|
|
|
apt:
|
|
|
|
update_cache: true
|
|
|
|
when: ansible_pkg_mgr == 'apt'
|
|
|
|
|
2020-01-14 18:07:32 +01:00
|
|
|
- name: Ensure HAProxy is installed
|
|
|
|
package:
|
|
|
|
name: haproxy
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Ensure HAProxy config directory exists
|
|
|
|
file:
|
|
|
|
path: /usr/local/etc/haproxy
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
- name: Ensure HAProxy is configured
|
|
|
|
template:
|
|
|
|
src: haproxy-loadbalancer.conf.j2
|
|
|
|
dest: /usr/local/etc/haproxy/haproxy.cfg
|
|
|
|
|
|
|
|
- name: Ensure HAProxy service is started
|
|
|
|
command: haproxy -D -f /usr/local/etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid
|
|
|
|
args:
|
|
|
|
creates: /var/run/haproxy.pid
|