0

I'm trying to install Ubuntu Server (64-bit) on a Raspberry PI 4B. I've created an image with the Raspberry Pi Imager, with a user/password and SSH enabled. The cloud-init script fails when trying to add the user:

2023-04-15 15:02:17,150 - __init__.py[DEBUG]: Adding user [USERNAME]
2023-04-15 15:02:17,151 - subp.py[DEBUG]: Running hidden command to protect sensitive input/output logstring: ['useradd', '[USERNAME]', '--groups', 'users,adm,dialout,audio,netdev,video,plugdev,cdrom,games,input,gpio,spi,i2c,render,sudo', '--password', 'REDACTED', '--shell', '/bin/bash', '-m']
2023-04-15 15:02:17,210 - util.py[WARNING]: Failed to create user [USERNAME]
2023-04-15 15:02:17,210 - util.py[DEBUG]: Failed to create user [USERNAME]
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/cloudinit/distros/__init__.py", line 608, in add_user
    subp.subp(useradd_cmd, logstring=log_useradd_cmd)
  File "/usr/lib/python3/dist-packages/cloudinit/subp.py", line 335, in subp
    raise ProcessExecutionError(
cloudinit.subp.ProcessExecutionError: Unexpected error while running command.
Command: ['useradd', '[USERNAME]', '--groups', 'users,adm,dialout,audio,netdev,video,plugdev,cdrom,games,input,gpio,spi,i2c,render,sudo', '--password', '[PASSWORD]', '--shell', '/bin/bash', '-m']
Exit code: 9
Reason: -
Stdout: 
Stderr: useradd: group [USERNAME] exists - if you want to add this user to that group, use -g.
2023-04-15 15:02:17,216 - handlers.py[DEBUG]: finish: init-local/config-users-groups: FAIL: running config-users-groups with frequency once-per-instance
2023-04-15 15:02:17,216 - 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
2023-04-15 15:02:17,216 - 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
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/cloudinit/config/modules.py", line 246, in _run_modules
    ran, _r = cc.run(
              ^^^^^^^
  File "/usr/lib/python3/dist-packages/cloudinit/cloud.py", line 67, in run
    return self._runners.run(name, functor, args, freq, clear_on_fail)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/cloudinit/helpers.py", line 185, in run
    results = functor(*args)
              ^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/cloudinit/config/cc_users_groups.py", line 211, in handle
    cloud.distro.create_user(user, **config)
  File "/usr/lib/python3/dist-packages/cloudinit/distros/__init__.py", line 665, in create_user
    self.add_user(name, **kwargs)
  File "/usr/lib/python3/dist-packages/cloudinit/distros/__init__.py", line 611, in add_user
    raise e
  File "/usr/lib/python3/dist-packages/cloudinit/distros/__init__.py", line 608, in add_user
    subp.subp(useradd_cmd, logstring=log_useradd_cmd)
  File "/usr/lib/python3/dist-packages/cloudinit/subp.py", line 335, in subp
    raise ProcessExecutionError(
cloudinit.subp.ProcessExecutionError: Unexpected error while running command.
Command: ['useradd', '[USERNAME]', '--groups', 'users,adm,dialout,audio,netdev,video,plugdev,cdrom,games,input,gpio,spi,i2c,render,sudo', '--password', '[PASSWORD]', '--shell', '/bin/bash', '-m']
Exit code: 9 

Any hints to what I do wrong?

5
  • "Created" an image? I'm not sure you can do that using the Raspberry Pi Imager. Do you mean you tried to flash an image you created? Or did you use the configuration on the Raspberry Pi Imager to do an unattended installation?
    – LilData777
    Commented Aug 25, 2023 at 13:11
  • I used the Imager to download, configure and flash an image onto an SD card to use in an Raspberry Pi
    – Mark
    Commented Aug 26, 2023 at 18:21
  • Have you possibly tried reflashing the SD card with Ubuntu again?
    – LilData777
    Commented Aug 29, 2023 at 11:42
  • The SD card had been used before, can that be a problem?
    – Mark
    Commented Aug 30, 2023 at 12:14
  • No it shouldn't be an issue.
    – LilData777
    Commented Aug 30, 2023 at 12:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.