From 3b32f95fb39a0faf810bf3aa6024d704d99c7156 Mon Sep 17 00:00:00 2001 From: Erwin Oegema Date: Tue, 4 Feb 2020 18:35:05 +0100 Subject: user - warn if "append" is set but not "groups" (#65795) This fixes people unknowingly changing the primary group rather than adding a secondary group. * Add integration test --- lib/ansible/modules/system/user.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/ansible/modules/system/user.py') diff --git a/lib/ansible/modules/system/user.py b/lib/ansible/modules/system/user.py index 6f4b8d0b11..2fada8d0fd 100644 --- a/lib/ansible/modules/system/user.py +++ b/lib/ansible/modules/system/user.py @@ -511,6 +511,12 @@ class User(object): else: self.ssh_file = os.path.join('.ssh', 'id_%s' % self.ssh_type) + if self.groups is None and self.append: + # Change the argument_spec in 2.14 and remove this warning + # required_by={'append': ['groups']} + module.warn("'append' is set, but no 'groups' are specified. Use 'groups' for appending new groups." + "This will change to an error in Ansible 2.14.") + def check_password_encrypted(self): # Darwin needs cleartext password, so skip validation if self.module.params['password'] and self.platform != 'Darwin': -- cgit v1.2.1