--- - 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 notify: Restart postfix - 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 notify: Restart postfix when: postfix_enabled | bool tags: [ 'postfix', 'postfix_conf', 'postfix_spf_policy' ] - 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 when: postfix_enabled | bool tags: [ 'postfix', 'postfix_conf' ] - name: Flush all the handlers related to postfix ansible.builtin.meta: flush_handlers