use become

This commit is contained in:
Robert Kaussow 2018-07-06 23:13:11 +02:00
parent 7e19f2faca
commit 0692148543
3 changed files with 63 additions and 57 deletions

View File

@ -1,5 +1,5 @@
---
- name: Restart postfix
- name: Restart service
service:
name: postfix
state: restarted

View File

@ -1,5 +1,7 @@
---
- name: Configure postfix
- name: Setup postfix
block:
- name: Configure postfix
template:
src: etc/postfix/main.cf.j2
dest: /etc/postfix/main.cf
@ -8,7 +10,7 @@
mode: 0644
notify: postfix_restart
- name: Create sasl
- name: Create sasl
template:
src: etc/postfix/sasl_passwd.j2
dest: /etc/postfix/sasl_passwd
@ -17,18 +19,18 @@
mode: 0600
register: sasl_result
- name: Ensure sasl_passwd.db exist
- name: Ensure sasl_passwd.db exist
stat:
path: /etc/postfix/sasl_passwd.db
register: sasldb
- name: Create sasl_passwd.db
- name: Create sasl_passwd.db
command: /usr/sbin/postmap hash:/etc/postfix/sasl_passwd
when: not sasldb.stat.exists or sasl_result.changed
register: sasldb_update
notify: postfix_restart
- name: Set permissions for sasl_passwd.db
- name: Set permissions for sasl_passwd.db
file:
path: /etc/postfix/sasl_passwd.db
owner: root
@ -36,7 +38,7 @@
mode: 0600
notify: postfix_restart
- name: Override outgoing header
- name: Override outgoing header
template:
src: etc/postfix/sender_canonical.j2
dest: /etc/postfix/sender_canonical
@ -45,13 +47,14 @@
mode: 0600
register: sender_result
- name: Ensure sender_canonical.db exist
- name: Ensure sender_canonical.db exist
stat:
path: /etc/postfix/sender_canonical.db
register: senderdb
- name: Hash sender_canoncial
- name: Hash sender_canoncial
command: "/usr/sbin/postmap hash:/etc/postfix/sender_canonical"
when: not senderdb.stat.exists or sender_result.changed
register: senderdb_update
notify: postfix_restart
become: True

View File

@ -1,5 +1,7 @@
---
- name: Install postfix mta
block:
- name: Install required packages
package:
name: '{{ item }}'
state: latest
@ -7,3 +9,4 @@
- postfix
- cyrus-sasl-plain
- mailx
become: True