← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1870310] [NEW] Explicit addition of a user's primary_group breaks the user creation

 

Public bug reported:

$ multipass launch --cloud-init - <<EOF
users:
- name: $USER
  groups: [ubuntu]
  ssh_authorized_keys:
  - $( cat ~/.ssh/id_rsa.pub )
EOF
# times out due to missing `ubuntu` user

$ multipass ls
# find the IP

$ ssh $IP

# /var/log/cloud-init.log
2020-04-02 09:40:27,551 - __init__.py[DEBUG]: Adding user ubuntu
2020-04-02 09:40:27,551 - util.py[DEBUG]: Running hidden command to protect sensitive input/output logstring: ['useradd', 'ubuntu', '--comment', 'Ubuntu', '--groups', 'adm,audio,cdrom,dialout,dip,floppy,lxd,netdev,plugdev,sudo,video', '--shell', '/bin/bash', '-m']
2020-04-02 09:40:27,555 - util.py[WARNING]: Failed to create user ubuntu
2020-04-02 09:40:27,556 - util.py[DEBUG]: Failed to create user ubuntu
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/cloudinit/distros/__init__.py", line 481, in add_user
    util.subp(useradd_cmd, logstring=log_useradd_cmd)
  File "/usr/lib/python3/dist-packages/cloudinit/util.py", line 2102, in subp
    cmd=args)
cloudinit.util.ProcessExecutionError: Unexpected error while running command.
Command: ['useradd', 'ubuntu', '--comment', 'Ubuntu', '--groups', 'adm,audio,cdrom,dialout,dip,floppy,lxd,netdev,plugdev,sudo,video', '--shell', '/bin/bash', '-m']
Exit code: 9
Reason: -
Stdout: 
Stderr: useradd: group ubuntu exists - if you want to add this user to that group, use -g.
2020-04-02 09:40:27,560 - handlers.py[DEBUG]: finish: init-network/config-users-groups: FAIL: running config-users-groups with frequency once-per-instance

It looks as if a user's primary_group is created prior to that user
being created, the user addition fails.

** Affects: cloud-init
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to cloud-init.
https://bugs.launchpad.net/bugs/1870310

Title:
  Explicit addition of a user's primary_group breaks the user creation

Status in cloud-init:
  New

Bug description:
  $ multipass launch --cloud-init - <<EOF
  users:
  - name: $USER
    groups: [ubuntu]
    ssh_authorized_keys:
    - $( cat ~/.ssh/id_rsa.pub )
  EOF
  # times out due to missing `ubuntu` user

  $ multipass ls
  # find the IP

  $ ssh $IP

  # /var/log/cloud-init.log
  2020-04-02 09:40:27,551 - __init__.py[DEBUG]: Adding user ubuntu
  2020-04-02 09:40:27,551 - util.py[DEBUG]: Running hidden command to protect sensitive input/output logstring: ['useradd', 'ubuntu', '--comment', 'Ubuntu', '--groups', 'adm,audio,cdrom,dialout,dip,floppy,lxd,netdev,plugdev,sudo,video', '--shell', '/bin/bash', '-m']
  2020-04-02 09:40:27,555 - util.py[WARNING]: Failed to create user ubuntu
  2020-04-02 09:40:27,556 - util.py[DEBUG]: Failed to create user ubuntu
  Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/cloudinit/distros/__init__.py", line 481, in add_user
      util.subp(useradd_cmd, logstring=log_useradd_cmd)
    File "/usr/lib/python3/dist-packages/cloudinit/util.py", line 2102, in subp
      cmd=args)
  cloudinit.util.ProcessExecutionError: Unexpected error while running command.
  Command: ['useradd', 'ubuntu', '--comment', 'Ubuntu', '--groups', 'adm,audio,cdrom,dialout,dip,floppy,lxd,netdev,plugdev,sudo,video', '--shell', '/bin/bash', '-m']
  Exit code: 9
  Reason: -
  Stdout: 
  Stderr: useradd: group ubuntu exists - if you want to add this user to that group, use -g.
  2020-04-02 09:40:27,560 - handlers.py[DEBUG]: finish: init-network/config-users-groups: FAIL: running config-users-groups with frequency once-per-instance

  It looks as if a user's primary_group is created prior to that user
  being created, the user addition fails.

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/1870310/+subscriptions


Follow ups