users task: check if /etc/aliases exists
This commit is contained in:
parent
081a0d1af6
commit
e8150bfc71
1 changed files with 8 additions and 1 deletions
|
@ -40,6 +40,11 @@
|
||||||
when: item.sudo == true
|
when: item.sudo == true
|
||||||
with_items: "{{ users }}"
|
with_items: "{{ users }}"
|
||||||
|
|
||||||
|
- name: Check if /etc/aliases exists
|
||||||
|
stat:
|
||||||
|
path: /etc/aliases
|
||||||
|
register: aliases
|
||||||
|
|
||||||
- name: Set system email alias
|
- name: Set system email alias
|
||||||
lineinfile:
|
lineinfile:
|
||||||
path: /etc/aliases
|
path: /etc/aliases
|
||||||
|
@ -47,5 +52,7 @@
|
||||||
regexp: "^{{ item.logname }}:"
|
regexp: "^{{ item.logname }}:"
|
||||||
line: "{{ item.logname }}: {{ item.email }}"
|
line: "{{ item.logname }}: {{ item.email }}"
|
||||||
notify: Update aliases
|
notify: Update aliases
|
||||||
when: item.email is defined
|
when:
|
||||||
|
- item.email is defined
|
||||||
|
- aliases.stat.exists
|
||||||
with_items: "{{ users }}"
|
with_items: "{{ users }}"
|
||||||
|
|
Loading…
Reference in a new issue