From 134fd61d6b44564c1a352bd639211940a646f26e Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Mon, 25 Nov 2019 18:58:52 -0600 Subject: [PATCH] Add mandatory interactive user group --- roles/users/defaults/main.yaml | 3 +++ roles/users/tasks/main.yaml | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/roles/users/defaults/main.yaml b/roles/users/defaults/main.yaml index d466b07..bf94418 100644 --- a/roles/users/defaults/main.yaml +++ b/roles/users/defaults/main.yaml @@ -1,2 +1,5 @@ --- user_default_shell: /bin/bash +user_default_groups: + - users +user_interactive_user_mandatory_groups: users diff --git a/roles/users/tasks/main.yaml b/roles/users/tasks/main.yaml index 531b29b..ea6174b 100644 --- a/roles/users/tasks/main.yaml +++ b/roles/users/tasks/main.yaml @@ -1,4 +1,10 @@ --- +- name: create the users group + group: + name: "{{ item }}" + state: present + loop: "{{ user_default_groups }}" + - name: ensure groups group: name: "{{ item.name }}" @@ -25,6 +31,14 @@ when: users_interactive is defined no_log: yes +- name: add users to default groups + user: + name: "{{ item.name }}" + groups: "{{ user_interactive_user_mandatory_groups | default(omit) }}" + append: yes + with_items: "{{ users_interactive }}" + when: users_interactive is defined and user_interactive_user_mandatory_groups is defined + - name: ensure system groups group: name: "{{ item.name }}"