users task: check if /etc/aliases exists

This commit is contained in:
Stefan Haun 2020-12-11 16:52:56 +01:00
parent 081a0d1af6
commit e8150bfc71

View file

@ -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 }}"