From 081a0d1af6b84a434f86dfd5806c2fd2dd1fa2d3 Mon Sep 17 00:00:00 2001 From: Stefan Haun Date: Fri, 11 Dec 2020 11:17:12 +0100 Subject: [PATCH] Set email aliases for users --- roles/users/tasks/main.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/roles/users/tasks/main.yml b/roles/users/tasks/main.yml index 38349e8..48c5ad0 100644 --- a/roles/users/tasks/main.yml +++ b/roles/users/tasks/main.yml @@ -39,3 +39,13 @@ append: yes when: item.sudo == true with_items: "{{ users }}" + +- name: Set system email alias + lineinfile: + path: /etc/aliases + state: present + regexp: "^{{ item.logname }}:" + line: "{{ item.logname }}: {{ item.email }}" + notify: Update aliases + when: item.email is defined + with_items: "{{ users }}"