diff --git a/roles/users/tasks/main.yml b/roles/users/tasks/main.yml index 48c5ad0..bc29637 100644 --- a/roles/users/tasks/main.yml +++ b/roles/users/tasks/main.yml @@ -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 }}"