63 lines
1.3 KiB
YAML
63 lines
1.3 KiB
YAML
---
|
|
# tasks file for postfix
|
|
- name: check postfix_aliases
|
|
assert:
|
|
that:
|
|
- item.name is defined
|
|
- item.destination is defined
|
|
when:
|
|
- postfix_aliases is defined
|
|
with_items:
|
|
- "{{ postfix_aliases }}"
|
|
|
|
- name: install postfix
|
|
package:
|
|
name: "{{ postfix_packages }}"
|
|
state: present
|
|
register: postfix_install_postfix
|
|
until: postfix_install_postfix
|
|
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: start and enable postfix
|
|
service:
|
|
name: "{{ postfix_service }}"
|
|
state: started
|
|
enabled: yes
|
|
when:
|
|
- ansible_virtualization_type != "docker"
|