07_antivirus.ymlΒΆ

---
# Register the ClamAV container as a DATA-stage milter (idempotent by host).
# Short timeouts + fail-open keep mail flowing while clamd warms up.
# JMAP request bodies live in templates/jmap/*.json.j2.
- name: "πŸ“– List existing Stalwart milters"
  include_tasks: jmap_call.yml
  vars:
    stalwart_jmap_body: "{{ lookup('template', 'jmap/milter/get.json.j2') }}"

- name: "πŸ” Resolve existing ClamAV milter id (if any)"
  ansible.builtin.set_fact:
    stalwart_av_milter_id: >-
      {{ (stalwart_jmap.methodResponses[0][1].list
          | selectattr('host', 'equalto', STALWART_CLAMAV_HOST)
          | map(attribute='id') | first) | default('') }}

- name: "πŸ“ Create the ClamAV milter"
  include_tasks: jmap_call.yml
  vars:
    stalwart_jmap_body: "{{ lookup('template', 'jmap/milter/create.json.j2') }}"
  when: stalwart_av_milter_id | length == 0

- name: "πŸ”„ Update the ClamAV milter timeouts (fail-open on slow/cold clamd)"
  include_tasks: jmap_call.yml
  vars:
    stalwart_jmap_body: "{{ lookup('template', 'jmap/milter/update.json.j2') }}"
  when: stalwart_av_milter_id | length > 0