61 lines
1.3 KiB
YAML
61 lines
1.3 KiB
YAML
---
|
|
# tasks file for postfix
|
|
- name: install postfix
|
|
package:
|
|
name: "{{ postfix_packages }}"
|
|
state: present
|
|
register: postfix_install_postfix
|
|
until: postfix_install_postfix is succeeded
|
|
retries: 3
|
|
|
|
- name: create group
|
|
group:
|
|
name: "{{ postfix_group }}"
|
|
state: present
|
|
|
|
- name: configure postfix (main.cf)
|
|
template:
|
|
src: main.cf.j2
|
|
dest: /etc/postfix/main.cf
|
|
validate: postconf -d -c %s
|
|
notify:
|
|
- restart postfix
|
|
|
|
- name: configure postfix (master.cf)
|
|
template:
|
|
src: master.cf.j2
|
|
dest: /etc/postfix/master.cf
|
|
validate: postconf -d -c %s
|
|
notify:
|
|
- restart postfix
|
|
|
|
- name: configure aliases
|
|
lineinfile:
|
|
path: "{{ postfix_alias_path }}"
|
|
regexp: "^{{ item.name }}:"
|
|
line: "{{ item.name }}: {{ item.destination }}"
|
|
when:
|
|
- postfix_aliases is defined
|
|
with_items:
|
|
- "{{ postfix_aliases }}"
|
|
notify:
|
|
- rebuild alias database
|
|
loop_control:
|
|
label: "{{ item.name }}"
|
|
|
|
- name: set group owner
|
|
file:
|
|
path: "{{ item }}"
|
|
group: "{{ postfix_group }}"
|
|
with_items:
|
|
- /usr/sbin/postqueue
|
|
- /usr/sbin/postdrop
|
|
- /var/spool/postfix/public
|
|
- /var/spool/postfix/maildrop
|
|
|
|
- name: start and enable postfix
|
|
service:
|
|
name: "{{ postfix_service }}"
|
|
state: started
|
|
enabled: yes
|