71 lines
1.7 KiB
YAML
71 lines
1.7 KiB
YAML
---
|
|
- name: check support
|
|
fail:
|
|
msg: Role not supported in your system
|
|
when: ansible_os_family != "RedHat"
|
|
|
|
- name: install postfix
|
|
package:
|
|
name: postfix
|
|
state: installed
|
|
|
|
- name: configure myhostname
|
|
lineinfile:
|
|
path: /etc/postfix/main.cf
|
|
regexp: '^myhostname\s*='
|
|
insertafter: '^#myhostname\s*='
|
|
line: "myhostname = {{ inventory_hostname }}"
|
|
notify: restart postfix
|
|
|
|
- name: configure myorigin
|
|
lineinfile:
|
|
path: /etc/postfix/main.cf
|
|
regexp: '^myorigin\s*='
|
|
insertafter: '^#myorigin\s*='
|
|
line: "myorigin = {{ mail_domain }}"
|
|
notify: restart postfix
|
|
when: mail_domain is defined
|
|
|
|
- name: configure mydestination
|
|
lineinfile:
|
|
path: /etc/postfix/main.cf
|
|
regexp: '^mydestination\s*='
|
|
insertafter: '^#mydestination\s*='
|
|
line: 'mydestination = ""'
|
|
notify: restart postfix
|
|
when:
|
|
- mail_domain is defined
|
|
- mail_server is defined
|
|
|
|
- name: configure relayhost
|
|
lineinfile:
|
|
path: /etc/postfix/main.cf
|
|
regexp: '^relayhost\s*='
|
|
insertafter: '^#relayhost\s*='
|
|
line: "relayhost = [{{ mail_server }}]:465"
|
|
notify: restart postfix
|
|
when: mail_server is defined
|
|
|
|
- name: configure smtp_tls_security_level
|
|
lineinfile:
|
|
path: /etc/postfix/main.cf
|
|
regexp: '^smtp_tls_security_level\s*='
|
|
insertafter: '^#?relayhost\s*='
|
|
line: "smtp_tls_security_level = encrypt"
|
|
notify: restart postfix
|
|
when: mail_server is defined
|
|
|
|
- name: configure smtp_tls_wrappermode
|
|
lineinfile:
|
|
path: /etc/postfix/main.cf
|
|
regexp: '^smtp_tls_wrappermode\s*='
|
|
insertafter: '^#?relayhost\s*='
|
|
line: "smtp_tls_wrappermode = yes"
|
|
notify: restart postfix
|
|
when: mail_server is defined
|
|
|
|
- name: enable postfix service
|
|
service:
|
|
name: postfix
|
|
state: started
|
|
enabled: true
|