docs: user-groups uses - instead of _

Bug #1420018 reported by Samuel Jean on 2015-02-09
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Low
do3meli

Bug Description

I am trying to add a user with a primary group that already exists with the same name as the user.

   default_user:
     name: docker
     lock_passwd: True
     gecos: Docker Administrator
     no-user-group: true
     primary-group: docker
     groups: [adm, audio, cdrom, dialout, dip, floppy, netdev, plugdev, sudo, video]
     sudo: ["ALL=(ALL) NOPASSWD:ALL"]
     shell: /bin/bash

2015-02-09 21:37:29,285 - __init__.py[DEBUG]: Adding user docker
2015-02-09 21:37:29,285 - util.py[DEBUG]: Running hidden command to protect sensitive input/output logstring: ['useradd', 'docker', '--shell', '/bin/bash', '--comment', 'Docker Administrator', '--groups', 'adm,audio,cdrom,dialout,dip,floppy,netdev,plugdev,sudo,video', '-m']
2015-02-09 21:37:29,312 - util.py[WARNING]: Failed to create user docker
2015-02-09 21:37:29,312 - util.py[DEBUG]: Failed to create user docker
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/cloudinit/distros/__init__.py", line 360, in add_user
    util.subp(adduser_cmd, logstring=log_adduser_cmd)
  File "/usr/lib/python2.7/dist-packages/cloudinit/util.py", line 1539, in subp
    cmd=args)
ProcessExecutionError: Unexpected error while running command.
Command: ['useradd', 'docker', '--shell', '/bin/bash', '--comment', 'Docker Administrator', '--groups', 'adm,audio,cdrom,dialout,dip,floppy,netdev,plugdev,sudo,video', '-m']
Exit code: 9
Reason: -
Stdout: ''
Stderr: 'useradd: group docker exists - if you want to add this user to that group, use -g.\n'

backdoor@docker:~$ dpkg -l | grep cloud-init
ii cloud-init 0.7.5-0ubuntu1.3 all Init scripts for cloud instances

Related branches

Samuel Jean (jseun) on 2015-02-09
description: updated
Samuel Jean (jseun) wrote :

Finally, the no_user_group works as expected.

From http://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/view/head:/cloudinit/distros/__init__.py :

        adduser_flags = {
            "no_user_group": '--no-user-group',
            "system": '--system',
            "no_log_init": '--no-log-init',
        }

However, the doc at http://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/view/head:/doc/examples/cloud-config-user-groups.txt speaks of no-user-group which does not work. The same would apply to no-log-init and no-create-home which should be no_log_init and no_create_home in the doc.

Am I missing something? Maybe this is expected to work with both underscores and dashes.

Joshua Powers (powersj) wrote :

Thank you for taking the time to report this bug. In an effort to keep
an up-to-date and valid list of bugs to work on, I have reviewed this
report verifying it still requires effort and occurs on a supported
version of Ubuntu.

It looks like you are correct and the docs say to use '-' when the
code is specifically looking for '_'.

The cloud-config-user-groups.txt file should be updated to reflect
the proper usage.

summary: - cannot create user with primary group if it exists already
+ docs: user-groups uses - instead of _
Changed in cloud-init:
status: New → Confirmed
importance: Undecided → Low
tags: added: bitesized docs
do3meli (d-info-e) on 2018-03-27
Changed in cloud-init:
assignee: nobody → do3meli (d-info-e)
do3meli (d-info-e) on 2018-03-27
Changed in cloud-init:
status: Confirmed → In Progress
Chad Smith (chad.smith) wrote :

An upstream commit landed for this bug.

To view that commit see the following URL:
https://git.launchpad.net/cloud-init/commit/?id=b27f713a

Changed in cloud-init:
status: In Progress → Fix Committed

This bug is believed to be fixed in cloud-init in version 18.3. If this is still a problem for you, please make a comment and set the state back to New

Thank you.

Changed in cloud-init:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers