forked from geerlingguy/ansible-role-haproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.yml
32 lines (27 loc) · 904 Bytes
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
---
- name: Ensure HAProxy is installed.
package: name=haproxy state=present
- name: Ensure HAProxy is enabled (so init script will start it on Debian).
lineinfile:
dest: /etc/default/haproxy
regexp: "^ENABLED.+$"
line: "ENABLED=1"
state: present
when: ansible_os_family == 'Debian'
- name: Get HAProxy version.
command: haproxy -v
register: haproxy_version_result
changed_when: false
check_mode: false
- name: Set HAProxy version.
set_fact:
haproxy_version: '{{ haproxy_version_result.stdout_lines[0] | regex_replace("^HA-?Proxy version (\d+(\.\d+)*).*$", "\1") }}'
- name: Copy HAProxy configuration in place.
template:
src: haproxy.cfg.j2
dest: /etc/haproxy/haproxy.cfg
mode: 0644
validate: haproxy -f %s -c -q
notify: restart haproxy
- name: Ensure HAProxy is started and enabled on boot.
service: name=haproxy state=started enabled=yes