You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
245 lines
5.8 KiB
YAML
245 lines
5.8 KiB
YAML
# tasks file
|
|
---
|
|
- name: facts | set
|
|
set_fact:
|
|
is_docker_guest: "{{ ansible_virtualization_role | default('host') == 'guest' and ansible_virtualization_type | default('none') == 'docker' }}"
|
|
tags:
|
|
- configuration
|
|
- postfix
|
|
- postfix-facts
|
|
|
|
- name: configure debconf
|
|
debconf:
|
|
name: "{{ item.name }}"
|
|
question: "{{ item.question }}"
|
|
value: "{{ item.value }}"
|
|
vtype: "{{ item.vtype }}"
|
|
with_items: "{{ postfix_debconf_selections }}"
|
|
tags:
|
|
- configuration
|
|
- postfix
|
|
- postfix-install
|
|
|
|
- name: install package
|
|
apt:
|
|
name: "{{ postfix_install }}"
|
|
state: "{{ apt_install_state | default('latest') }}"
|
|
update_cache: true
|
|
cache_valid_time: "{{ apt_update_cache_valid_time | default(3600) }}"
|
|
tags:
|
|
- configuration
|
|
- postfix
|
|
- postfix-install
|
|
|
|
- name: configure mailname
|
|
template:
|
|
src: "{{ postfix_mailname_file.lstrip('/') }}.j2"
|
|
dest: "{{ postfix_mailname_file }}"
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
notify: restart postfix
|
|
tags:
|
|
- configuration
|
|
- postfix
|
|
- postfix-mailname
|
|
|
|
- name: update configuration file
|
|
template:
|
|
src: "{{ postfix_main_cf.lstrip('/') }}.j2"
|
|
dest: "{{ postfix_main_cf }}"
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
notify: restart postfix
|
|
tags:
|
|
- configuration
|
|
- postfix
|
|
- postfix-configuration
|
|
|
|
- name: configure sasl username/password
|
|
template:
|
|
src: "{{ postfix_sasl_passwd_file.lstrip('/') }}.j2"
|
|
dest: "{{ postfix_sasl_passwd_file }}"
|
|
owner: root
|
|
group: root
|
|
mode: 0600
|
|
when:
|
|
- postfix_relayhost | length
|
|
- postfix_sasl_auth_enable | bool
|
|
no_log: "{{ not ansible_check_mode }}"
|
|
notify:
|
|
- postmap sasl_passwd
|
|
- restart postfix
|
|
tags:
|
|
- configuration
|
|
- postfix
|
|
- postfix-sasl-passwd
|
|
|
|
- name: configure aliases
|
|
template:
|
|
src: "{{ postfix_aliases_file.lstrip('/') }}.j2"
|
|
dest: "{{ postfix_aliases_file }}"
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
notify:
|
|
- new aliases
|
|
- restart postfix
|
|
tags:
|
|
- configuration
|
|
- postfix
|
|
- postfix-aliases
|
|
|
|
- name: check if aliases.db exists
|
|
stat:
|
|
path: "{{ postfix_aliases_file }}.db"
|
|
register: _aliasesdb
|
|
changed_when: not _aliasesdb.stat.exists
|
|
when: postfix_default_database_type == 'hash'
|
|
notify:
|
|
- new aliases
|
|
- restart postfix
|
|
tags:
|
|
- configuration
|
|
- postfix
|
|
- postfix-aliases
|
|
|
|
- name: configure virtual aliases
|
|
lineinfile:
|
|
dest: "{{ postfix_virtual_aliases_file }}"
|
|
regexp: '^{{ item.virtual | regex_escape }}\s.*'
|
|
line: '{{ item.virtual }} {{ item.alias }}'
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
create: true
|
|
state: present
|
|
with_items: "{{ postfix_virtual_aliases }}"
|
|
notify:
|
|
- new virtual aliases
|
|
- restart postfix
|
|
tags:
|
|
- configuration
|
|
- postfix
|
|
- postfix-virtual-aliases
|
|
|
|
- name: configure sender canonical maps
|
|
lineinfile:
|
|
dest: "{{ postfix_sender_canonical_maps_file }}"
|
|
regexp: '^{{ item.sender | regex_escape }}\s.*'
|
|
line: '{{ item.sender }} {{ item.rewrite }}'
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
create: true
|
|
state: present
|
|
with_items: "{{ postfix_sender_canonical_maps }}"
|
|
notify:
|
|
- postmap sender_canonical_maps
|
|
- restart postfix
|
|
tags:
|
|
- configuration
|
|
- postfix
|
|
- postfix-sender-canonical-maps
|
|
|
|
- name: configure recipient canonical maps
|
|
lineinfile:
|
|
dest: "{{ postfix_recipient_canonical_maps_file }}"
|
|
regexp: '^{{ item.recipient | regex_escape }}\s.*'
|
|
line: '{{ item.recipient }} {{ item.rewrite }}'
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
create: true
|
|
state: present
|
|
with_items: "{{ postfix_recipient_canonical_maps }}"
|
|
notify:
|
|
- postmap recipient_canonical_maps
|
|
- restart postfix
|
|
tags:
|
|
- configuration
|
|
- postfix
|
|
- postfix-recipient-canonical-maps
|
|
|
|
- name: configure transport maps
|
|
lineinfile:
|
|
dest: "{{ postfix_transport_maps_file }}"
|
|
regexp: '^{{ item.pattern | regex_escape }}\s.*'
|
|
line: '{{ item.pattern }} {{ item.result }}'
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
create: true
|
|
state: present
|
|
with_items: "{{ postfix_transport_maps }}"
|
|
notify:
|
|
- postmap transport_maps
|
|
- restart postfix
|
|
tags:
|
|
- configuration
|
|
- postfix
|
|
- postfix-transport-maps
|
|
|
|
- name: configure sender dependent relayhost maps
|
|
lineinfile:
|
|
dest: "{{ postfix_sender_dependent_relayhost_maps_file }}"
|
|
regexp: '^{{ item.pattern | regex_escape }}\s.*'
|
|
line: '{{ item.pattern }} {{ item.result }}'
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
create: true
|
|
state: present
|
|
with_items: "{{ postfix_sender_dependent_relayhost_maps }}"
|
|
notify:
|
|
- postmap sender_dependent_relayhost_maps
|
|
- restart postfix
|
|
tags:
|
|
- configuration
|
|
- postfix
|
|
- postfix-sender-dependent-relayhost-maps
|
|
|
|
- name: configure generic table
|
|
lineinfile:
|
|
dest: "{{ postfix_smtp_generic_maps_file }}"
|
|
regexp: '^{{ item.pattern | regex_escape }}\s.*'
|
|
line: '{{ item.pattern }} {{ item.result }}'
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
create: true
|
|
state: present
|
|
with_items: "{{ postfix_smtp_generic_maps }}"
|
|
notify:
|
|
- postmap generic
|
|
- restart postfix
|
|
tags:
|
|
- configuration
|
|
- postfix
|
|
- postfix-generic-table
|
|
|
|
- name: configure header checks
|
|
template:
|
|
src: "{{ postfix_header_checks_file.lstrip('/') }}.j2"
|
|
dest: "{{ postfix_header_checks_file }}"
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
notify:
|
|
- restart postfix
|
|
tags:
|
|
- configuration
|
|
- postfix
|
|
- postfix-header-checks-table
|
|
|
|
- name: start and enable service
|
|
service:
|
|
name: postfix
|
|
state: "{{ service_default_state | default('started') }}"
|
|
enabled: "{{ service_default_enabled | default(true) | bool }}"
|
|
tags:
|
|
- configuration
|
|
- postfix
|
|
- postfix-start-enable-service
|