Comment 4 for bug 1562918

When I remove the groups: part I get the following errors in the /var/log/cloud-init.log:

Mar 31 22:35:45 test [CLOUDINIT] stages.py[DEBUG]: Running module users-groups (<module 'cloudinit.config.cc_users_groups' from '/usr/lib/python3/dist-packages/
cloudinit/config/cc_users_groups.py'>) with frequency once-per-instance
Mar 31 22:35:45 test [CLOUDINIT] handlers.py[DEBUG]: start: init-network/config-users-groups: running config-users-groups with frequency once-per-instance
Mar 31 22:35:45 test [CLOUDINIT] util.py[DEBUG]: Writing to /var/lib/cloud/instances/nocloud/sem/config_users_groups - wb: [420] 24 bytes
Mar 31 22:35:45 test [CLOUDINIT] helpers.py[DEBUG]: Running config-users-groups using lock (<FileLock using file '/var/lib/cloud/instances/nocloud/sem/config_us
ers_groups'>)
Mar 31 22:35:45 test [CLOUDINIT] __init__.py[DEBUG]: Adding user ansible
Mar 31 22:35:45 test [CLOUDINIT] util.py[DEBUG]: Running hidden command to protect sensitive input/output logstring: ['useradd', 'ansible', '--shell', '/bin/bash', '--gid', 'ansible', '--comment', 'Ansible', '--groups', 'sudo', '-m']
Mar 31 22:35:45 test [CLOUDINIT] util.py[WARNING]: Failed to create user ansible
Mar 31 22:35:46 test [CLOUDINIT] util.py[DEBUG]: Failed to create user ansible#012Traceback (most recent call last):#012 File "/usr/lib/python3/dist-packages/cloudinit/distros/__init__.py", line 406, in add_user#012 util.subp(adduser_cmd, logstring=log_adduser_cmd)#012 File "/usr/lib/python3/dist-packages/cloudinit/util.py", line 1704, in subp#012 cmd=args)#012cloudinit.util.ProcessExecutionError: Unexpected error while running command.#012Command: ['useradd', 'ansible', '--shell', '/bin/bash', '--gid', 'ansible', '--comment', 'Ansible', '--groups', 'sudo', '-m']#012Exit code: 6#012Reason: -#012Stdout: ''#012Stderr: "useradd: group 'ansible' does not exist\n"
Mar 31 22:35:46 test [CLOUDINIT] handlers.py[DEBUG]: finish: init-network/config-users-groups: FAIL: running config-users-groups with frequency once-per-instance
Mar 31 22:35:46 test [CLOUDINIT] util.py[WARNING]: Running module users-groups (<module 'cloudinit.config.cc_users_groups' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_users_groups.py'>) failed
Mar 31 22:35:46 test [CLOUDINIT] util.py[DEBUG]: Running module users-groups (<module 'cloudinit.config.cc_users_groups' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_users_groups.py'>) failed#012Traceback (most recent call last):#012 File "/usr/lib/python3/dist-packages/cloudinit/stages.py", line 735, in _run_modules#012 freq=freq)#012 File "/usr/lib/python3/dist-packages/cloudinit/cloud.py", line 70, in run#012 return self._runners.run(name, functor, args, freq, clear_on_fail)#012 File "/usr/lib/python3/dist-packages/cloudinit/helpers.py", line 199, in run#012 results = functor(*args)#012 File "/usr/lib/python3/dist-packages/cloudinit/config/cc_users_groups.py", line 34, in handle#012 cloud.distro.create_user(user, **config)#012 File "/usr/lib/python3/dist-packages/cloudinit/distros/__init__.py", line 419, in create_user#012 self.add_user(name, **kwargs)#012 File "/usr/lib/python3/dist-packages/cloudinit/distros/__init__.py", line 409, in add_user#012 raise e#012 File "/usr/lib/python3/dist-packages/cloudinit/distros/__init__.py", line 406, in add_user#012 util.subp(adduser_cmd, logstring=log_adduser_cmd)#012 File "/usr/lib/python3/dist-packages/cloudinit/util.py", line 1704, in subp#012 cmd=args)#012cloudinit.util.ProcessExecutionError: Unexpected error while running command.#012Command: ['useradd', 'ansible', '--shell', '/bin/bash', '--gid', 'ansible', '--comment', 'Ansible', '--groups', 'sudo', '-m']#012Exit code: 6#012Reason: -#012Stdout: ''#012Stderr: "useradd: group 'ansible' does not exist\n"
Mar 31 22:35:46 test [CLOUDINIT] stages.py[DEBUG]: Running module ssh (<module 'cloudinit.config.cc_ssh' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_ssh.py'>) with frequency once-per-instance