From e8150bfc7160a2daa5c9344b9ea3ce4287a0ee95 Mon Sep 17 00:00:00 2001 From: Stefan Haun Date: Fri, 11 Dec 2020 16:52:56 +0100 Subject: [PATCH] users task: check if /etc/aliases exists --- roles/users/tasks/main.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 }}"