ansible-role-postfix/tasks/smtp-configuration.yml

55 lines
2.0 KiB
YAML

---
- name: Postfix main configuration
block:
- name: Write the postfix main configuration file
template: src=main.cf.j2 dest=/etc/postfix/main.cf owner=root group=root mode=0444
register: postfix_main_restart_needed
- name: The postfix master.cf file adapts to the service role
template: src=master.cf.j2 dest=/etc/postfix/master.cf owner=root group=root mode=0444
register: postfix_master_restart_needed
when: postfix_enabled | bool
tags: [ 'postfix', 'postfix_conf' ]
- name: Postfix maps installation
block:
- name: Write the postfix network_table map
template: src=network_table.j2 dest=/etc/postfix/network_table owner=root group=root mode=0444
register: postfix_network_table_status
- name: Write the postfix virtual_domains map
template: src=virtual_domains.j2 dest=/etc/postfix/virtual_domains owner=root group=root mode=0444
register: postfix_virtual_domains_status
- name: Write the postfix transport map
template: src=transport.j2 dest=/etc/postfix/transport owner=root group=root mode=0444
register: postfix_transport_table_status
when: postfix_transport_map_enabled | bool
- name: Update the network hash table
shell: postmap hash:/etc/postfix/network_table
when: postfix_network_table_status is changed
- name: Update the virtual_domains
shell: postmap hash:/etc/postfix/virtual_domains
when: postfix_virtual_domains_status is changed
- name: Update the transport hash table
shell: postmap hash:/etc/postfix/transport
when: postfix_transport_table_status is changed
when: postfix_enabled | bool
tags: [ 'postfix', 'postfix_conf', 'postfix_maps' ]
- block:
- name: Ensure that postfix is started and enabled
service: name=postfix state=started enabled=yes
- name: Restart postfix
service: name=postfix state=restarted
when: ( postfix_main_restart_needed is changed ) or ( postfix_master_restart_needed is changed )
when: postfix_enabled | bool
tags: [ 'postfix', 'postfix_conf' ]