gpg-lacre/tasks/simple_filter.yml

52 lines
1.8 KiB
YAML

---
- name: '[LACRE] - Add simple filter launcher script'
template:
src: templates/usr/local/bin/lacre-simple_filter.sh.j2
dest: /usr/local/bin/lacre-simple_filter.sh
owner: '{{ lacre_username }}'
group: '{{ lacre_group }}'
mode: '0755'
- name: '[LACRE] - Add lacre simple filter to postfix'
blockinfile:
dest: '/etc/postfix/master.cf'
backup: yes
marker: '# {mark} LACRE config block (Ansible)'
block: |
lacre unix - n n - - pipe
flags= user={{ lacre_username }}
argv=bash /usr/local/bin/lacre-simple_filter.sh
127.0.0.1:10028 inet n - n - 10 smtpd
-o content_filter=
-o receive_override_options=no_unknown_recipient_checks,no_header_body_checks
-o smtpd_helo_restrictions=
-o smtpd_client_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks=127.0.0.0/8
-o smtpd_authorized_xforward_hosts=127.0.0.0/8
when: lacre_postfix_simplefilter == 'true'
- name: '[LACRE] - Check if content_filter is set in postfix'
shell: "grep -q 'content_filter' /etc/postfix/main.cf"
register: check_filter
ignore_errors: true
- name: '[LACRE] - Add content filter in postfix settings if not exists'
lineinfile:
path: '/etc/postfix/main.cf'
line: 'content_filter = {{ lacre_content_filter }}'
insertafter: EOF
state: present
when: lacre_set_content_filter == 'true' and check_filter.rc !=0
- name: '[LACRE] - Replace content_filter setting in postfix'
replace:
path: '/etc/postfix/main.cf'
regexp: 'content_filter = .*'
replace: 'content_filter = {{ lacre_content_filter }}'
when: lacre_set_content_filter == 'true' and check_filter.rc == 0