diff --git a/tasks/acl.yml b/tasks/acl.yml index e2e2155..e9ba7d4 100644 --- a/tasks/acl.yml +++ b/tasks/acl.yml @@ -2,23 +2,27 @@ --- - name: acl | create directories ansible.builtin.file: - path: "{{ item.dest | dirname }}" + path: "{{ acl_file.dest | dirname }}" state: directory - owner: "{{ item.owner | default('root') }}" - group: "{{ item.group | default('root') }}" + owner: "{{ acl_file.owner | default('root') }}" + group: "{{ acl_file.group | default('root') }}" mode: '0750' - with_items: "{{ haproxy_acl_files }}" + loop: "{{ haproxy_acl_files }}" + loop_control: + loop_var: acl_file tags: - haproxy-acl-create-directories - name: acl | update files ansible.builtin.template: src: etc/haproxy/acl.j2 - dest: "{{ item.dest }}" - owner: "{{ item.owner | default('root') }}" - group: "{{ item.group | default('root') }}" - mode: "{{ item.mode | default('0640') }}" - with_items: "{{ haproxy_acl_files }}" + dest: "{{ acl_file.dest }}" + owner: "{{ acl_file.owner | default('root') }}" + group: "{{ acl_file.group | default('root') }}" + mode: "{{ acl_file.mode | default('0640') }}" + loop: "{{ haproxy_acl_files }}" + loop_control: + loop_var: acl_file notify: restart haproxy tags: - haproxy-acl-update-files diff --git a/tasks/certificates.yml b/tasks/certificates.yml index c03e393..17bd891 100644 --- a/tasks/certificates.yml +++ b/tasks/certificates.yml @@ -2,35 +2,41 @@ --- - name: certificates | create directories ansible.builtin.file: - path: "{{ item.dest | dirname }}" + path: "{{ ssl_map.dest | dirname }}" state: directory - owner: "{{ item.owner | default('root') }}" - group: "{{ item.group | default('root') }}" + owner: "{{ ssl_map.owner | default('root') }}" + group: "{{ ssl_map.group | default('root') }}" mode: '0750' - with_items: "{{ haproxy_ssl_map }}" - when: item.state is undefined or item.state == 'present' + loop: "{{ haproxy_ssl_map }}" + loop_control: + loop_var: ssl_map + when: ssl_map.state is undefined or ssl_map.state == 'present' tags: - haproxy-certificates-create-directories - name: certificates | copy files ansible.builtin.copy: - src: "{{ item.src }}" - dest: "{{ item.dest }}" - owner: "{{ item.owner | default('root') }}" - group: "{{ item.group | default('root') }}" - mode: "{{ item.mode | default('0640') }}" - with_items: "{{ haproxy_ssl_map }}" - when: item.state is undefined or item.state == 'present' + src: "{{ ssl_map.src }}" + dest: "{{ ssl_map.dest }}" + owner: "{{ ssl_map.owner | default('root') }}" + group: "{{ ssl_map.group | default('root') }}" + mode: "{{ ssl_map.mode | default('0640') }}" + loop: "{{ haproxy_ssl_map }}" + loop_control: + loop_var: ssl_map + when: ssl_map.state is undefined or ssl_map.state == 'present' notify: restart haproxy tags: - haproxy-certificates-copy-files - name: certificates | remove files ansible.builtin.file: - path: "{{ item.dest }}" + path: "{{ ssl_map.dest }}" state: absent - with_items: "{{ haproxy_ssl_map }}" - when: item.state is defined and item.state == 'absent' + loop: "{{ haproxy_ssl_map }}" + loop_control: + loop_var: ssl_map + when: ssl_map.state is defined and ssl_map.state == 'absent' notify: restart haproxy tags: - haproxy-certificates-remove-files diff --git a/tasks/install.yml b/tasks/install.yml index 973e6e2..91db4e1 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -2,9 +2,11 @@ --- - name: install | dependencies ansible.builtin.apt: - name: "{{ item.name }}" - state: "{{ item.state }}" - with_items: "{{ haproxy_dependencies }}" + name: "{{ dep.name }}" + state: "{{ dep.state }}" + loop: "{{ haproxy_dependencies }}" + loop_control: + loop_var: dep tags: - haproxy-install-dependencies diff --git a/tasks/repository.yml b/tasks/repository.yml index 52a1ae2..9e88f18 100644 --- a/tasks/repository.yml +++ b/tasks/repository.yml @@ -30,18 +30,22 @@ - name: repository | cleanup ansible.builtin.file: - path: "{{ item }}" + path: "{{ repo_path }}" state: absent - with_items: "{{ haproxy_repository_files_absent }}" + loop: "{{ haproxy_repository_files_absent }}" + loop_control: + loop_var: repo_path tags: - haproxy-repository-cleanup - name: repository | add ansible.builtin.apt_repository: - repo: "{{ item.type }} {{ item.url }} {{ item.component }}" - state: "{{ item.state | default('present') }}" + repo: "{{ repo.type }} {{ repo.url }} {{ repo.component }}" + state: "{{ repo.state | default('present') }}" update_cache: true mode: '0644' - with_items: "{{ haproxy_repositories }}" + loop: "{{ haproxy_repositories }}" + loop_control: + loop_var: repo tags: - haproxy-repository-add diff --git a/templates/usr/local/bin/haproxy-letsencrypt-ocsp-deploy.j2 b/templates/usr/local/bin/haproxy-letsencrypt-ocsp-deploy.j2 index 11ba29a..5a01bdd 100644 --- a/templates/usr/local/bin/haproxy-letsencrypt-ocsp-deploy.j2 +++ b/templates/usr/local/bin/haproxy-letsencrypt-ocsp-deploy.j2 @@ -37,7 +37,7 @@ done find "{{ haproxy_global_crt_base }}" -mindepth 1 -name "*.ocsp" -mtime +0 -delete; -{% if ansible_service_mgr == 'systemd' %} +{% if ansible_facts['service_mgr'] == 'systemd' %} systemctl reload haproxy; {% else %} service haproxy reload; diff --git a/vars/main.yml b/vars/main.yml index 6561cba..5d8413c 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -24,12 +24,12 @@ haproxy_keyring_id: 3D653970FBAB0A890E4E4E9A0F14D8B0CF4EFE96 haproxy_keyring_dst: /usr/share/keyrings/haproxy.gpg haproxy_repositories: - type: "deb [signed-by={{ haproxy_keyring_dst }}]" - url: "https://ppa.launchpadcontent.net/vbernat/haproxy-{{ haproxy_version }}/{{ ansible_distribution | lower }} {{ ansible_distribution_release }}" + url: "https://ppa.launchpadcontent.net/vbernat/haproxy-{{ haproxy_version }}/{{ ansible_facts['distribution'] | lower }} {{ ansible_facts['distribution_release'] }}" component: main _haproxy_version_sources_list_d: "{{ (haproxy_version | string).split('.') | join('_') }}" haproxy_repository_files_absent: - - "/etc/apt/sources.list.d/ppa_vbernat_haproxy_{{ _haproxy_version_sources_list_d }}_{{ ansible_distribution_release }}.list" - - "/etc/apt/sources.list.d/ppa_vbernat_haproxy_{{ _haproxy_version_sources_list_d }}_{{ ansible_distribution_release }}.list.save" + - "/etc/apt/sources.list.d/ppa_vbernat_haproxy_{{ _haproxy_version_sources_list_d }}_{{ ansible_facts['distribution_release'] }}.list" + - "/etc/apt/sources.list.d/ppa_vbernat_haproxy_{{ _haproxy_version_sources_list_d }}_{{ ansible_facts['distribution_release'] }}.list.save" haproxy_dependencies_pre: - software-properties-common