diff --git a/tasks/certpaths.yml b/tasks/certpaths.yml index 80ac930e204f7c5c211ca46ec01f8043a8248c82..ae2e7eb54dbfb63bc1862a9d36c35deaa8a9ac02 100644 --- a/tasks/certpaths.yml +++ b/tasks/certpaths.yml @@ -1,6 +1,6 @@ --- - name: "Generate certpaths file for {{ item.name }}" - notify: reload haproxy + notify: Reload haproxy ansible.builtin.template: src: certpaths.j2 dest: "/etc/haproxy/{{ item.name }}.certpaths" diff --git a/tasks/configure.yml b/tasks/configure.yml index a398c8641ac6c62048adc2cbb3d0ccb6e4a1d66f..6732b9f0f745ad479b8d477151046c982bfe136d 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -104,6 +104,20 @@ ## ASSEMBLE CONFIG - HTTP-ERRORS +- name: Create directory for the error files + ansible.builtin.file: + path: "{{ haproxy_config_dir }}/error" + state: directory + owner: root + group: root + mode: "0755" + +- name: Copy error pages + ansible.builtin.copy: + src: "{{ inventory_hostname }}/error/" + dest: "{{ haproxy_config_dir }}/error" + mode: "0644" + - name: 'Create directory for the http-errors' ansible.builtin.file: path: "{{ haproxy_config_dir }}/http-errors.d" @@ -123,12 +137,12 @@ ansible.builtin.file: path: "{{ item.path }}" state: absent - when: (item.path | basename) not in (haproxy_http-errors | json_query('[*].name') | map('regex_replace', '(^.*$)', '\\1.cfg') | list) + when: (item.path | basename) not in (haproxy_http_errors | json_query('[*].name') | map('regex_replace', '(^.*$)', '\\1.cfg') | list) loop: "{{ directory_contents.files }}" - name: 'Build up the http-errors' ansible.builtin.template: - src: "backend.cfg" + src: "http-errors.cfg" dest: "{{ haproxy_config_dir }}/http-errors.d/{{ item.name }}.cfg" owner: root group: root @@ -289,4 +303,4 @@ group: root mode: "0644" backup: true - notify: reload haproxy + notify: Reload haproxy diff --git a/tasks/tls.yml b/tasks/tls.yml index 9a776cef897b170a3608db2cfa2c2433c2f0a8a8..1a9fdbcbb035da319ac041248a7880cd90bcf508 100644 --- a/tasks/tls.yml +++ b/tasks/tls.yml @@ -9,6 +9,6 @@ register: result changed_when: "result.stdout" when: not cert.stat.exists - notify: restart haproxy + notify: Restart haproxy tags: - skip_ansible_lint diff --git a/templates/frontend.cfg b/templates/frontend.cfg index ccefa3ff445bb3eb1600b36789b76b2e42861192..94c321755d9c855a194c35b100dadd009917808c 100644 --- a/templates/frontend.cfg +++ b/templates/frontend.cfg @@ -114,6 +114,6 @@ frontend {{ item.name }} {%if item.ip is defined %}{{ item.ip }}{% endif %}{%if {% endfor -%} {% endif -%} - {%- if item.errorfiles -%} - errorfiles {% item.errorfiles %} + {%- if item.errorfiles is defined -%} + errorfiles {{ item.errorfiles }} {% endif %} diff --git a/templates/http-errors.cfg b/templates/http-errors.cfg index c273a3afd790c24689c3a0329852f3a56598d913..b012531c8ba5aea31bcb5e1e231000dfc0aa0c51 100644 --- a/templates/http-errors.cfg +++ b/templates/http-errors.cfg @@ -5,3 +5,5 @@ http-errors {{ item.name }} {% if item.errorfiles is defined %} {%- for errorfile in item.errorfiles -%} errorfile {{ errorfile.status }} {{ errorfile.file }} + {% endfor -%} + {% endif -%}