--- - name: Apply postfix configuration lineinfile: dest: "{{item.dest}}" regexp: "{{item.regexp}}" line: "{{item.line}}" insertafter: EOF notify: Restart Postfix with_items: - { dest: /etc/postfix/main.cf, regexp: "inet_protocols =", line: "inet_protocols = ipv4" } - { dest: /etc/postfix/main.cf, regexp: "inet_interfaces =", line: "inet_interfaces = all" } - { dest: /etc/postfix/main.cf, regexp: "relayhost =", line: "relayhost = {{ relayhost }}" } when: "'SMTP' not in inventory_hostname" - name: Ensure Postfix is Started/Enabled service: name: postfix state: started enabled: yes - name: Ensure root forwarding address is set lineinfile: dest: ~/.forward regexp: "{{ root_email }}" line: "{{ root_email }}" create: yes