2020-01-12 13:50:03 +01:00
|
|
|
---
|
2020-12-21 20:14:52 +01:00
|
|
|
- name: Prepare Load Balancer
|
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
|
2020-12-12 15:27:59 +01:00
|
|
|
ansible.builtin.apt:
|
2020-02-22 15:33:12 +01:00
|
|
|
update_cache: true
|
|
|
|
when: ansible_pkg_mgr == 'apt'
|
|
|
|
|
2020-01-14 18:07:32 +01:00
|
|
|
- name: Ensure HAProxy is installed
|
2020-12-12 15:27:59 +01:00
|
|
|
ansible.builtin.package:
|
2020-01-14 18:07:32 +01:00
|
|
|
name: haproxy
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Ensure HAProxy config directory exists
|
2020-12-12 15:27:59 +01:00
|
|
|
ansible.builtin.file:
|
2020-01-14 18:07:32 +01:00
|
|
|
path: /usr/local/etc/haproxy
|
|
|
|
state: directory
|
2020-09-26 16:50:03 +02:00
|
|
|
mode: 0755
|
2020-01-14 18:07:32 +01:00
|
|
|
|
|
|
|
- name: Ensure HAProxy is configured
|
2020-12-12 15:27:59 +01:00
|
|
|
ansible.builtin.template:
|
2020-01-14 18:07:32 +01:00
|
|
|
src: haproxy-loadbalancer.conf.j2
|
|
|
|
dest: /usr/local/etc/haproxy/haproxy.cfg
|
2020-09-26 16:50:03 +02:00
|
|
|
mode: 0644
|
2020-01-14 18:07:32 +01:00
|
|
|
|
|
|
|
- name: Ensure HAProxy service is started
|
2021-04-10 13:15:51 +02:00
|
|
|
ansible.builtin.command:
|
|
|
|
cmd: haproxy -D -f /usr/local/etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid
|
2020-01-14 18:07:32 +01:00
|
|
|
args:
|
|
|
|
creates: /var/run/haproxy.pid
|
2020-12-21 20:14:52 +01:00
|
|
|
|
|
|
|
- name: Prepare nodes
|
|
|
|
hosts: node*
|
|
|
|
tasks:
|
2021-12-19 22:41:59 +01:00
|
|
|
- name: Ensure apt cache is updated and iptables is installed
|
2020-12-21 20:14:52 +01:00
|
|
|
ansible.builtin.apt:
|
2021-12-19 22:41:59 +01:00
|
|
|
name: iptables
|
|
|
|
state: present
|
2020-12-21 20:14:52 +01:00
|
|
|
update_cache: true
|
|
|
|
when: ansible_pkg_mgr == 'apt'
|
2021-12-19 00:04:24 +01:00
|
|
|
|
|
|
|
- name: Ensure iproute is installed
|
|
|
|
ansible.builtin.dnf:
|
|
|
|
name: iproute
|
|
|
|
state: present
|
|
|
|
update_cache: true
|
|
|
|
when: ansible_pkg_mgr == 'dnf'
|