From 29ef364fab3ea35f98283393d076f9083595647e Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Wed, 12 Jun 2024 18:28:16 -0500 Subject: [PATCH] r/haproxy: Clean up for modern haproxy versions The current version of *haproxy* packaged in Fedora already enables configuration via fragments in a drop-in directory, though it uses a different path by default. I still like separating the global configuration from the defaults, though, and keeping the main `haproxy.cfg` file empty. --- roles/haproxy/files/haproxy-config.conf | 2 -- roles/haproxy/tasks/main.yml | 44 +++++++++++-------------- 2 files changed, 20 insertions(+), 26 deletions(-) delete mode 100644 roles/haproxy/files/haproxy-config.conf diff --git a/roles/haproxy/files/haproxy-config.conf b/roles/haproxy/files/haproxy-config.conf deleted file mode 100644 index c5504da..0000000 --- a/roles/haproxy/files/haproxy-config.conf +++ /dev/null @@ -1,2 +0,0 @@ -[Service] -Environment=CONFIG=/etc/haproxy diff --git a/roles/haproxy/tasks/main.yml b/roles/haproxy/tasks/main.yml index 28ce10b..9346f1e 100644 --- a/roles/haproxy/tasks/main.yml +++ b/roles/haproxy/tasks/main.yml @@ -11,39 +11,35 @@ tags: - install -- name: ensure haproxy unit configuration extension directory exists - file: - path=/etc/systemd/system/haproxy.service.d - mode=0755 - state=directory -- name: ensure haproxy config variable override is set - copy: - src=haproxy-config.conf - dest=/etc/systemd/system/haproxy.service.d/config.conf - mode=0644 - notify: - - reload systemd - - restart haproxy - name: ensure default haproxy configuration file is empty copy: - src=haproxy.cfg - dest=/etc/haproxy - mode=0644 + src: haproxy.cfg + dest: /etc/haproxy + mode: u=rw,go=r notify: restart haproxy - name: ensure haproxy global configuration is set template: - src=global.cfg.j2 - dest=/etc/haproxy/10-global.cfg - mode=0644 + src: global.cfg.j2 + dest: /etc/haproxy/conf.d/10-global.cfg + mode: u=rw,go=r notify: restart haproxy - name: ensure haproxy defaults are set template: - src=defaults.cfg.j2 - dest=/etc/haproxy/20-defaults.cfg - mode=0644 + src: defaults.cfg.j2 + dest: /etc/haproxy/conf.d/20-defaults.cfg + mode: u=rw,go=r notify: restart haproxy - name: ensure haproxy starts at boot service: - name=haproxy - enabled=yes + name: haproxy + enabled: true + tags: + - service + +- name: ensure haproxy is running + service: + name: haproxy + state: started + tags: + - service