diff --git a/defaults/main.yml b/defaults/main.yml index 033a84f..856958b 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -194,6 +194,9 @@ clamav_freshclam_custom_urls: [] clamav_milter_socket: 'local:/run/clamav-milter/clamav-milter.socket' clamav_milter_use_whitelist_file: false clamav_milter_whitelist_file: '/etc/mail/clamav-whitelist' +# List of POSIX BRE patterns, one per line, optionally prefixed with "From:" or "To:". +# Example: 'From:^.*@example\.org$' +clamav_milter_whitelist: [] clamav_milter_use_skip_authenticated_file: false clamav_milter_skip_authenticated_file: '/etc/mail/clamav-skip-authenticated' clamav_milter_onclean_action: 'Accept' diff --git a/tasks/main.yml b/tasks/main.yml index 69410bb..c633cf7 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -130,17 +130,28 @@ tags: [ 'clamav', 'clamav_urlhaus' ] - name: Configure the clamav milter + when: clamav_milter_install | bool + tags: ['clamav', 'clamav_clamd', 'clamav_config', 'clamav_milter'] block: - name: Install the clamav milter configuration template: src=clamav-milter.conf.j2 dest=/etc/mail/clamav-milter.conf owner=root group=root mode=0444 notify: Restart clamav-milter + - name: Install the clamav milter whitelist file + template: src=clamav-milter-whitelist.j2 dest={{ clamav_milter_whitelist_file }} owner=root group=root mode=0444 + notify: Restart clamav-milter + when: clamav_milter_use_whitelist_file | bool and clamav_milter_whitelist | length > 0 + tags: [ 'clamav', 'clamav_clamd', 'clamav_config', 'clamav_whitelist' ] + + - name: Remove the clamav milter whitelist file when not in use + file: dest={{ clamav_milter_whitelist_file }} state=absent + notify: Restart clamav-milter + when: not (clamav_milter_use_whitelist_file | bool) or clamav_milter_whitelist | length == 0 + tags: [ 'clamav', 'clamav_clamd', 'clamav_config', 'clamav_whitelist' ] + - name: Ensure that clamav milter is running and enabled service: name=clamav-milter state=started enabled=yes - when: clamav_milter_install | bool - tags: [ 'clamav', 'clamav_clamd', 'clamav_config' ] - - name: Configure the clamd service used by spamassassin block: - name: Install the clamd configuration for the spamassassin service diff --git a/templates/clamav-milter-whitelist.j2 b/templates/clamav-milter-whitelist.j2 new file mode 100644 index 0000000..475a30b --- /dev/null +++ b/templates/clamav-milter-whitelist.j2 @@ -0,0 +1,7 @@ +# {{ ansible_managed }} +# clamav-milter Whitelist file. +# Each line is a POSIX BRE; optionally prefixed with "From:" or "To:". +# If the prefix is missing "To:" is assumed. +{% for entry in clamav_milter_whitelist %} +{{ entry }} +{% endfor %}