diff --git a/tasks/acmesh.yml b/tasks/acmesh.yml index 8864f4d..7d4b556 100644 --- a/tasks/acmesh.yml +++ b/tasks/acmesh.yml @@ -14,13 +14,12 @@ - --install-cronjob become: true +# One include per command: a failing command stops the host, so a --deploy +# never runs after a failed --issue (a plain loop would continue). - name: Execute acme.sh commands - ansible.builtin.command: - argv: "{{ item.command }}" - creates: "{{ item.must_present | default(omit) }}" - removes: "{{ item.must_absent | default(omit) }}" - become: true + ansible.builtin.include_tasks: + file: acmesh_command.yml loop: "{{ haproxy_acmesh }}" loop_control: - label: "{{ item.command | join(' ') }}" - environment: "{{ item.env }}" + loop_var: haproxy_acmesh_item + label: "{{ haproxy_acmesh_item.name | default(haproxy_acmesh_item.command | join(' ')) }}" diff --git a/tasks/acmesh_command.yml b/tasks/acmesh_command.yml new file mode 100644 index 0000000..3fb2146 --- /dev/null +++ b/tasks/acmesh_command.yml @@ -0,0 +1,10 @@ +--- +# tasks file for haproxy + +- name: "Execute acme.sh command: {{ haproxy_acmesh_item.name | default(haproxy_acmesh_item.command | join(' ')) }}" + ansible.builtin.command: + argv: "{{ haproxy_acmesh_item.command }}" + creates: "{{ haproxy_acmesh_item.must_present | default(omit) }}" + removes: "{{ haproxy_acmesh_item.must_absent | default(omit) }}" + become: true + environment: "{{ haproxy_acmesh_item.env | default({}) }}"