Initial version of postfix role
This commit is contained in:
parent
f490804106
commit
c8f65fc7bd
2 changed files with 74 additions and 0 deletions
5
roles/postfix/handlers/main.yml
Normal file
5
roles/postfix/handlers/main.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- name: restart postfix
|
||||
service:
|
||||
name: postfix
|
||||
state: restarted
|
69
roles/postfix/tasks/main.yml
Normal file
69
roles/postfix/tasks/main.yml
Normal file
|
@ -0,0 +1,69 @@
|
|||
---
|
||||
- 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 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 masquerade_classes
|
||||
lineinfile:
|
||||
path: /etc/postfix/main.cf
|
||||
regexp: '^masquerade_classes\s*='
|
||||
insertafter: '^#?relayhost\s*='
|
||||
line: "masquerade_classes = envelope_sender"
|
||||
notify: restart postfix
|
||||
when: mail_domain is defined
|
||||
|
||||
- name: configure masquerade_domains
|
||||
lineinfile:
|
||||
path: /etc/postfix/main.cf
|
||||
regexp: '^masquerade_domains\s*='
|
||||
insertafter: '^masquerade_classes\s*='
|
||||
line: "masquerade_domains = {{ mail_domain }}"
|
||||
notify: restart postfix
|
||||
when: mail_domain 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_security_level
|
||||
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
|
Loading…
Add table
Add a link
Reference in a new issue