99 lines
2.3 KiB
YAML
99 lines
2.3 KiB
YAML
---
|
|
# tasks file for postfix
|
|
|
|
- name: include assert.yml
|
|
import_tasks: assert.yml
|
|
run_once: yes
|
|
delegate_to: localhost
|
|
|
|
- name: pre-configure debian systems
|
|
ansible.builtin.debconf:
|
|
name: postfix
|
|
question: postfix/main_mailer_type
|
|
vtype: string
|
|
value: "No configuration"
|
|
when:
|
|
- ansible_os_family == "Debian"
|
|
|
|
- name: install postfix
|
|
ansible.builtin.package:
|
|
name: "{{ postfix_packages }}"
|
|
state: present
|
|
|
|
- name: configure postfix (main.cf)
|
|
ansible.builtin.template:
|
|
src: main.cf.j2
|
|
dest: /etc/postfix/main.cf
|
|
validate: postconf -d -c %s
|
|
mode: "0644"
|
|
notify:
|
|
- reload postfix
|
|
|
|
- name: configure postfix (master.cf)
|
|
ansible.builtin.template:
|
|
src: master.cf.j2
|
|
dest: /etc/postfix/master.cf
|
|
validate: postconf -d -c %s
|
|
mode: "0644"
|
|
notify:
|
|
- restart postfix
|
|
|
|
- name: force all notified handlers to run
|
|
ansible.builtin.meta: flush_handlers
|
|
|
|
- name: configure aliases
|
|
ansible.builtin.lineinfile:
|
|
path: "{{ postfix_alias_path }}"
|
|
regexp: "^{{ item.name }}:"
|
|
line: "{{ item.name }}: {{ item.destination }}"
|
|
mode: "0644"
|
|
when:
|
|
- postfix_aliases is defined
|
|
loop: "{{ postfix_aliases }}"
|
|
notify:
|
|
- rebuild alias database
|
|
- reload postfix
|
|
loop_control:
|
|
label: "{{ item.name }}"
|
|
|
|
- name: configure sender_access
|
|
ansible.builtin.lineinfile:
|
|
path: "{{ postfix_sender_access_path }}"
|
|
regexp: "^{{ item.domain }}"
|
|
line: "{{ item.domain }} {{ item.action }}"
|
|
create: yes
|
|
mode: "0644"
|
|
when:
|
|
- postfix_sender_access is defined
|
|
loop: "{{ postfix_sender_access }}"
|
|
notify:
|
|
- rebuild sender_access database
|
|
- reload postfix
|
|
loop_control:
|
|
label: "{{ item.domain }}"
|
|
|
|
- name: configure recipient_access
|
|
ansible.builtin.lineinfile:
|
|
path: "{{ postfix_recipient_access_path }}"
|
|
regexp: "^{{ item.domain }}"
|
|
line: "{{ item.domain }} {{ item.action }}"
|
|
create: yes
|
|
mode: "0644"
|
|
when:
|
|
- postfix_recipient_access is defined
|
|
loop: "{{ postfix_recipient_access }}"
|
|
notify:
|
|
- rebuild recipient_access database
|
|
- reload postfix
|
|
loop_control:
|
|
label: "{{ item.domain }}"
|
|
|
|
- name: force all notified handlers to run
|
|
ansible.builtin.meta: flush_handlers
|
|
|
|
- name: start and enable postfix
|
|
ansible.builtin.service:
|
|
name: "{{ postfix_service }}"
|
|
state: started
|
|
enabled: yes
|