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:
|
|
|
|
- name: Ensure apt cache is updated
|
|
|
|
ansible.builtin.apt:
|
|
|
|
update_cache: true
|
|
|
|
when: ansible_pkg_mgr == 'apt'
|
2021-12-19 20:02:31 +01:00
|
|
|
|
|
|
|
- name: Ensure environment file exists for k3s_service_env_file
|
|
|
|
ansible.builtin.lineinfile:
|
|
|
|
path: /tmp/k3s.env
|
|
|
|
line: "THISHOST={{ ansible_hostname }}"
|
|
|
|
mode: 0644
|