2014-12-07 23:35:44 +00:00
---
# Tasks to set up haproxy
2025-01-14 20:18:57 +10:00
- name : Install needed packages
2024-12-19 13:22:42 +10:00
ansible.builtin.package : name={{ item }} state=present
2014-12-07 23:35:44 +00:00
with_items :
- haproxy
2022-06-06 12:22:35 -07:00
- socat
2014-12-07 23:35:44 +00:00
tags :
- packages
2015-01-06 19:35:41 +00:00
- haproxy
2014-12-07 23:35:44 +00:00
2025-01-14 20:18:57 +10:00
- name : Install haproxy/cfg
2025-01-13 12:24:19 +10:00
ansible.builtin.template : src={{ item.file }}
2014-12-07 23:35:44 +00:00
dest={{ item.dest }}
owner=root group=root mode=0600
with_items :
- { file: haproxy.cfg, dest : /etc/haproxy/haproxy.cfg }
2015-01-06 19:40:05 +00:00
notify :
2025-02-07 13:51:07 +01:00
- Restart haproxy
2015-01-06 19:40:05 +00:00
tags :
- haproxy
2025-01-14 20:18:57 +10:00
- name : Install limits.conf and 503.http
2024-12-18 08:23:28 +10:00
ansible.builtin.copy : src={{ item.file }}
2014-12-07 23:35:44 +00:00
dest={{ item.dest }}
owner=root group=root mode=0600
with_items :
- { file: limits.conf, dest : /etc/security/limits.conf }
- { file: 503.http, dest : /etc/haproxy/503.http }
2015-01-06 19:35:41 +00:00
tags :
- haproxy
2015-01-06 19:45:58 +00:00
2025-01-14 20:18:57 +10:00
- name : Install pem cert
2024-12-18 08:23:28 +10:00
ansible.builtin.copy : src={{ item.file }}
2016-08-04 21:23:07 +00:00
dest={{ item.dest }}
owner=root group=root mode=0600
with_items :
2021-08-13 16:37:13 -07:00
- { file : "ipa.{{env}}-iad2.pem" , dest : /etc/haproxy/ipa.pem }
2021-08-19 16:13:33 -07:00
- { file : "ocp.{{env_short}}-iad2.pem" , dest : "/etc/haproxy/ocp-{{env_short}}.pem" }
2016-08-04 21:23:07 +00:00
tags :
- haproxy
2025-01-14 20:18:57 +10:00
- name : Install ocp api pem cert
2024-12-18 08:23:28 +10:00
ansible.builtin.copy : src={{ private }}/files/httpd/api-int.ocp{{ env_suffix }}.fedoraproject.org.pem
2021-08-09 10:49:21 -07:00
dest=/etc/haproxy/ocp4.pem
owner=root group=root mode=0600
tags :
- haproxy
2021-09-08 12:32:42 +09:00
2025-01-14 20:18:57 +10:00
- name : Install libsemanage
2024-12-19 13:22:42 +10:00
ansible.builtin.package :
2019-12-05 22:21:11 +00:00
state : present
name :
- libsemanage-python
2015-01-06 19:45:58 +00:00
tags :
2019-12-05 22:54:36 +00:00
- haproxy
2019-12-05 22:21:11 +00:00
- selinux
when : (ansible_distribution == 'RedHat' and ansible_distribution_major_version|int < 8) or (ansible_distribution_major_version|int < 30 and ansible_distribution == 'Fedora')
2025-01-14 20:18:57 +10:00
- name : Install libsemanage in a python3 manner
2024-12-19 13:22:42 +10:00
ansible.builtin.package :
2019-12-05 22:21:11 +00:00
state : present
name :
- python3-libsemanage
tags :
2019-12-05 22:54:36 +00:00
- haproxy
2015-01-06 19:45:58 +00:00
- selinux
2019-12-05 22:21:11 +00:00
when : (ansible_distribution_major_version|int >= 30 and ansible_distribution == 'Fedora') or (ansible_distribution == 'RedHat' and ansible_distribution_major_version|int >= 8)
2015-01-06 19:45:58 +00:00
- name : Turn on certain selinux booleans so haproxy can bind to ports
seboolean : name={{ item }} state=true persistent=true
with_items :
- haproxy_connect_any
tags :
- haproxy
- selinux
2015-01-06 19:53:19 +00:00
# These following four tasks are used for copying over our custom selinux
# module.
2025-01-14 20:18:57 +10:00
- name : Ensure a directory exists for our custom selinux module
2024-12-17 15:31:55 +10:00
ansible.builtin.file : dest=/usr/share/haproxy state=directory
2015-01-06 19:53:19 +00:00
tags :
- haproxy
- selinux
2025-01-14 20:18:57 +10:00
- name : Copy over our general haproxy selinux module
2024-12-18 08:23:28 +10:00
ansible.builtin.copy : src=selinux/fi-haproxy.pp dest=/usr/share/haproxy/fi-haproxy.pp
2015-01-06 19:53:19 +00:00
register : fi_haproxy_module
tags :
- haproxy
- selinux
2025-01-14 20:18:57 +10:00
- name : Check to see if its even installed yet
2024-12-19 16:42:30 +10:00
ansible.builtin.shell : semodule -l | grep fi-haproxy | wc -l
2015-01-06 19:53:19 +00:00
register : fi_haproxy_grep
2016-11-01 16:29:49 +00:00
check_mode : no
2015-01-06 19:53:19 +00:00
changed_when : "'0' in fi_haproxy_grep.stdout"
tags :
- haproxy
- selinux
2025-01-14 20:18:57 +10:00
- name : Install our general haproxy selinux module
2024-12-19 11:22:24 +10:00
ansible.builtin.command : semodule -i /usr/share/haproxy/fi-haproxy.pp
2018-05-07 23:51:48 +00:00
when : fi_haproxy_module is changed or fi_haproxy_grep is changed
2015-01-06 19:53:19 +00:00
tags :
- haproxy
- selinux
2015-08-19 01:18:31 +00:00
2025-01-14 20:18:57 +10:00
- name : Check haproxy cfg to make sure it is valid
2024-12-19 11:22:24 +10:00
ansible.builtin.command : haproxy -c -f /etc/haproxy/haproxy.cfg
2016-11-01 16:29:49 +00:00
check_mode : no
2015-08-19 01:18:31 +00:00
register : haproxyconfigcheck
changed_when : haproxyconfigcheck.rc != 0
tags :
- haproxy
- name : Make sure haproxy is awake and reporting for duty
service : name=haproxy state=started enabled=yes
tags :
- haproxy