Move postfix configuration to block

This commit is contained in:
2018-06-27 21:13:40 +12:00
parent 3b2de81b2b
commit b6d7c14c2d

View File

@@ -1,36 +1,39 @@
--- ---
- name: Apply postfix configuration - name: Postfix Configuration
lineinfile: block:
dest: "{{item.dest}}" - name: postfix | Apply postfix configuration
regexp: "{{item.regexp}}" lineinfile:
line: "{{item.line}}" dest: "{{item.dest}}"
insertafter: EOF regexp: "{{item.regexp}}"
notify: Restart Postfix line: "{{item.line}}"
when: "'SMTP0' not in inventory_hostname" insertafter: EOF
with_items: notify: Restart Postfix
- { dest: /etc/postfix/main.cf, when: "'SMTP0' not in inventory_hostname"
regexp: "inet_protocols =", with_items:
line: "inet_protocols = ipv4" - { dest: /etc/postfix/main.cf,
} regexp: "inet_protocols =",
- { dest: /etc/postfix/main.cf, line: "inet_protocols = ipv4"
regexp: "inet_interfaces =", }
line: "inet_interfaces = all" - { dest: /etc/postfix/main.cf,
} regexp: "inet_interfaces =",
- { dest: /etc/postfix/main.cf, line: "inet_interfaces = all"
regexp: "relayhost =", }
line: "relayhost = {{ relayhost }}" - { dest: /etc/postfix/main.cf,
} regexp: "relayhost =",
- { line: "relayhost = {{ relayhost }}"
dest: /etc/postfix/main.cf, }
regexp: "smtp_randomize_addresses =", - {
line: "smtp_randomize_addresses = no" dest: /etc/postfix/main.cf,
} regexp: "smtp_randomize_addresses =",
line: "smtp_randomize_addresses = no"
}
- name: Ensure Postfix is Started/Enabled - name: postfix | Ensure Postfix is Started/Enabled
service: service:
name: postfix name: postfix
state: started state: started
enabled: yes enabled: yes
when: "{{ postfix_configure }}"
- name: Ensure root forwarding address is set - name: Ensure root forwarding address is set
lineinfile: lineinfile: