2016-11-17 13:41:44 +13:00
|
|
|
---
|
2018-06-27 21:13:40 +12:00
|
|
|
- name: Postfix Configuration
|
2023-10-05 17:06:16 +13:00
|
|
|
when: postfix_configure
|
2018-06-27 21:13:40 +12:00
|
|
|
block:
|
2023-10-08 22:34:46 +13:00
|
|
|
- name: Postfix | Apply postfix configuration
|
2018-06-27 21:13:40 +12:00
|
|
|
lineinfile:
|
2022-11-02 11:51:16 +13:00
|
|
|
dest: "{{ configurations.dest }}"
|
|
|
|
|
regexp: "{{ configurations.regexp }}"
|
|
|
|
|
line: "{{ configurations.line }}"
|
2018-06-27 21:13:40 +12:00
|
|
|
insertafter: EOF
|
|
|
|
|
notify: Restart Postfix
|
|
|
|
|
when: "'SMTP0' not in inventory_hostname"
|
|
|
|
|
with_items:
|
2022-04-03 13:20:47 +12:00
|
|
|
- {
|
|
|
|
|
dest: /etc/postfix/main.cf,
|
2019-01-22 09:06:04 +13:00
|
|
|
regexp: "^.?inet_protocols =",
|
2022-04-03 13:20:47 +12:00
|
|
|
line: "inet_protocols = ipv4",
|
2018-06-27 21:13:40 +12:00
|
|
|
}
|
2022-04-03 13:20:47 +12:00
|
|
|
- {
|
|
|
|
|
dest: /etc/postfix/main.cf,
|
2019-01-22 09:06:04 +13:00
|
|
|
regexp: "^.?inet_interfaces =",
|
2022-04-03 13:20:47 +12:00
|
|
|
line: "inet_interfaces = all",
|
2018-06-27 21:13:40 +12:00
|
|
|
}
|
2022-04-03 13:20:47 +12:00
|
|
|
- {
|
|
|
|
|
dest: /etc/postfix/main.cf,
|
2019-01-22 09:06:04 +13:00
|
|
|
regexp: "^.?relayhost =",
|
2022-04-03 13:20:47 +12:00
|
|
|
line: "relayhost = {{ relayhost }}",
|
2018-06-27 21:13:40 +12:00
|
|
|
}
|
|
|
|
|
- {
|
|
|
|
|
dest: /etc/postfix/main.cf,
|
2019-01-22 09:06:04 +13:00
|
|
|
regexp: "^.?smtp_randomize_addresses =",
|
2022-04-03 13:20:47 +12:00
|
|
|
line: "smtp_randomize_addresses = no",
|
2018-06-27 21:13:40 +12:00
|
|
|
}
|
2022-11-02 11:51:16 +13:00
|
|
|
loop_control:
|
|
|
|
|
loop_var: configurations
|
2016-11-17 13:41:44 +13:00
|
|
|
|
2023-10-08 22:34:46 +13:00
|
|
|
- name: Postfix | Ensure Postfix is Started/Enabled
|
2018-06-27 21:13:40 +12:00
|
|
|
service:
|
|
|
|
|
name: postfix
|
|
|
|
|
state: started
|
|
|
|
|
enabled: yes
|
2016-11-17 13:41:44 +13:00
|
|
|
|
|
|
|
|
- name: Ensure root forwarding address is set
|
|
|
|
|
lineinfile:
|
|
|
|
|
dest: ~/.forward
|
2022-03-11 20:21:44 +13:00
|
|
|
regexp: "{{ common_root_email }}"
|
|
|
|
|
line: "{{ common_root_email }}"
|
2019-01-22 09:06:04 +13:00
|
|
|
create: yes
|