From c2446e870934df7d29bc0f85a06ebaf28332f6d2 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Sat, 9 Sep 2017 08:12:00 +0000 Subject: [PATCH] Support the append argument to the user module When true, this argument prevents removal of an existing user from groups not listed in the groups argument. --- README.md | 1 + tasks/main.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 31a41f2..468b32f 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ The following attributes are required for each user: - 'on_create' will only set the password for newly created users. * group - optional primary group override * groups - a list of supplementary groups for the user. +* append - if yes, will only add groups, not set them to just the list in groups (optional). * profile - a string block for setting custom shell profiles * ssh_key - This should be a list of ssh keys for the user (optional). Each ssh key should be included directly and should have no newlines. diff --git a/tasks/main.yml b/tasks/main.yml index c0348a2..ab90fbf 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -17,6 +17,7 @@ group: "{{item.group | default(item.username if users_create_per_user_group else users_group)}}" # empty string removes user from all secondary groups groups: "{{item.groups | join(',') if 'groups' in item else ''}}" + append: "{{item.append | default(omit)}}" shell: "{{item.shell if item.shell is defined else users_default_shell}}" password: "{{item.password if item.password is defined else '!'}}" comment: "{{item.name if item.name is defined else ''}}"