postfix: ansible-lint fixes
This commit is contained in:
parent
5864d92d43
commit
d72649632f
2 changed files with 115 additions and 100 deletions
|
@ -1,10 +1,10 @@
|
|||
---
|
||||
- name: restart postfix
|
||||
service:
|
||||
- name: Restart postfix
|
||||
ansible.builtin.service:
|
||||
name: postfix
|
||||
state: restarted
|
||||
|
||||
- name: restart stunnel-smtps
|
||||
service:
|
||||
- name: Restart stunnel-smtps
|
||||
ansible.builtin.service:
|
||||
name: stunnel-smtps
|
||||
state: restarted
|
||||
|
|
|
@ -1,135 +1,150 @@
|
|||
---
|
||||
- name: check support
|
||||
fail:
|
||||
msg: Role not supported in your system
|
||||
when: ansible_os_family != "RedHat"
|
||||
|
||||
- name: install postfix
|
||||
package:
|
||||
- name: Install postfix
|
||||
ansible.builtin.package:
|
||||
name: postfix
|
||||
state: installed
|
||||
|
||||
- name: set postfix as system mta
|
||||
alternatives:
|
||||
- name: Set postfix as system mta
|
||||
community.general.alternatives:
|
||||
name: mta
|
||||
path: /usr/sbin/sendmail.postfix
|
||||
|
||||
- name: configure myhostname
|
||||
lineinfile:
|
||||
- name: Configure myhostname
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/postfix/main.cf
|
||||
regexp: '^myhostname\s*='
|
||||
insertafter: '^#myhostname\s*='
|
||||
line: "myhostname = {{ inventory_hostname }}"
|
||||
notify: restart postfix
|
||||
notify: Restart postfix
|
||||
|
||||
- name: configure myorigin
|
||||
lineinfile:
|
||||
- name: Configure myorigin
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/postfix/main.cf
|
||||
regexp: '^myorigin\s*='
|
||||
insertafter: '^#myorigin\s*='
|
||||
line: "myorigin = {{ mail_domain }}"
|
||||
notify: restart postfix
|
||||
notify: Restart postfix
|
||||
when: mail_domain is defined
|
||||
|
||||
- name: configure mydestination
|
||||
lineinfile:
|
||||
- name: Configure mydestination
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/postfix/main.cf
|
||||
regexp: '^mydestination\s*='
|
||||
insertafter: '^#mydestination\s*='
|
||||
line: 'mydestination = ""'
|
||||
notify: restart postfix
|
||||
notify: Restart postfix
|
||||
when:
|
||||
- mail_domain is defined
|
||||
- mail_server is defined
|
||||
|
||||
- block:
|
||||
- name: install stunnel
|
||||
package:
|
||||
name: stunnel
|
||||
state: installed
|
||||
|
||||
- name: create group smtps
|
||||
group:
|
||||
name: smtps
|
||||
system: true
|
||||
|
||||
- name: create user smtps
|
||||
user:
|
||||
name: smtps
|
||||
comment: Service Stunnel-SMTPS
|
||||
createhome: false
|
||||
group: smtps
|
||||
home: /var/empty
|
||||
shell: /sbin/nologin
|
||||
system: true
|
||||
|
||||
- name: create stunnel config
|
||||
template:
|
||||
src: stunnel.conf.j2
|
||||
dest: /etc/stunnel/smtps.conf
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: "{{ ansible_wheel }}"
|
||||
notify: restart stunnel-smtps
|
||||
|
||||
- name: create stunnel systemd service
|
||||
copy:
|
||||
src: stunnel-smtps.service
|
||||
dest: /etc/systemd/system/stunnel-smtps.service
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: "{{ ansible_wheel }}"
|
||||
notify: restart stunnel-smtps
|
||||
|
||||
- name: enable stunnel service
|
||||
service:
|
||||
name: stunnel-smtps
|
||||
state: started
|
||||
enabled: true
|
||||
|
||||
- name: configure relayhost
|
||||
lineinfile:
|
||||
path: /etc/postfix/main.cf
|
||||
regexp: '^relayhost\s*='
|
||||
insertafter: '^#relayhost\s*='
|
||||
line: "relayhost = [localhost]:2525"
|
||||
notify: restart postfix
|
||||
|
||||
- name: Install stunnel
|
||||
ansible.builtin.package:
|
||||
name: stunnel
|
||||
state: installed
|
||||
when:
|
||||
- ansible_distribution_major_version|int < 8
|
||||
- ansible_distribution_major_version|int <= 7
|
||||
- mail_server is defined
|
||||
|
||||
- block:
|
||||
- name: configure relayhost
|
||||
lineinfile:
|
||||
path: /etc/postfix/main.cf
|
||||
regexp: '^relayhost\s*='
|
||||
insertafter: '^#relayhost\s*='
|
||||
line: "relayhost = [{{ mail_server }}]:465"
|
||||
notify: restart postfix
|
||||
- name: Create group smtps
|
||||
ansible.builtin.group:
|
||||
name: smtps
|
||||
system: true
|
||||
when:
|
||||
- ansible_distribution_major_version|int <= 7
|
||||
- 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
|
||||
- name: Create user smtps
|
||||
ansible.builtin.user:
|
||||
name: smtps
|
||||
comment: Service Stunnel-SMTPS
|
||||
createhome: false
|
||||
group: smtps
|
||||
home: /var/empty
|
||||
shell: /sbin/nologin
|
||||
system: true
|
||||
when:
|
||||
- ansible_distribution_major_version|int <= 7
|
||||
- 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
|
||||
- name: Create stunnel config
|
||||
ansible.builtin.template:
|
||||
src: stunnel.conf.j2
|
||||
dest: /etc/stunnel/smtps.conf
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: "{{ ansible_wheel }}"
|
||||
notify: Restart stunnel-smtps
|
||||
when:
|
||||
- ansible_distribution_major_version|int <= 7
|
||||
- mail_server is defined
|
||||
|
||||
- name: Create stunnel systemd service
|
||||
ansible.builtin.copy:
|
||||
src: stunnel-smtps.service
|
||||
dest: /etc/systemd/system/stunnel-smtps.service
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: "{{ ansible_wheel }}"
|
||||
notify: Restart stunnel-smtps
|
||||
when:
|
||||
- ansible_distribution_major_version|int <= 7
|
||||
- mail_server is defined
|
||||
|
||||
- name: Enable stunnel service
|
||||
ansible.builtin.service:
|
||||
name: stunnel-smtps
|
||||
state: started
|
||||
enabled: true
|
||||
when:
|
||||
- ansible_distribution_major_version|int <= 7
|
||||
- mail_server is defined
|
||||
|
||||
- name: Configure relayhost
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/postfix/main.cf
|
||||
regexp: '^relayhost\s*='
|
||||
insertafter: '^#relayhost\s*='
|
||||
line: "relayhost = [localhost]:2525"
|
||||
notify: Restart postfix
|
||||
when:
|
||||
- ansible_distribution_major_version|int <= 7
|
||||
- mail_server is defined
|
||||
|
||||
- name: Configure relayhost
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/postfix/main.cf
|
||||
regexp: '^relayhost\s*='
|
||||
insertafter: '^#relayhost\s*='
|
||||
line: "relayhost = [{{ mail_server }}]:465"
|
||||
notify: Restart postfix
|
||||
when:
|
||||
- ansible_distribution_major_version|int >= 8
|
||||
- mail_server is defined
|
||||
|
||||
- name: enable postfix service
|
||||
service:
|
||||
- name: Configure smtp_tls_security_level
|
||||
ansible.builtin.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:
|
||||
- ansible_distribution_major_version|int >= 8
|
||||
- mail_server is defined
|
||||
|
||||
- name: Configure smtp_tls_wrappermode
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/postfix/main.cf
|
||||
regexp: '^smtp_tls_wrappermode\s*='
|
||||
insertafter: '^#?relayhost\s*='
|
||||
line: "smtp_tls_wrappermode = yes"
|
||||
notify: Restart postfix
|
||||
when:
|
||||
- ansible_distribution_major_version|int >= 8
|
||||
- mail_server is defined
|
||||
|
||||
- name: Enable postfix service
|
||||
ansible.builtin.service:
|
||||
name: postfix
|
||||
state: started
|
||||
enabled: true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue