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
|
||||
with_items: "{{ users }}"
|
||||
|
||||
- name: Check if /etc/aliases exists
|
||||
stat:
|
||||
path: /etc/aliases
|
||||
register: aliases
|
||||
|
||||
- name: Set system email alias
|
||||
lineinfile:
|
||||
path: /etc/aliases
|
||||
|
@ -47,5 +52,7 @@
|
|||
regexp: "^{{ item.logname }}:"
|
||||
line: "{{ item.logname }}: {{ item.email }}"
|
||||
notify: Update aliases
|
||||
when: item.email is defined
|
||||
when:
|
||||
- item.email is defined
|
||||
- aliases.stat.exists
|
||||
with_items: "{{ users }}"
|
||||
|
|
Loading…
Reference in a new issue