Score:0

Cloud-init Always Adding Ubuntu User?

fk flag

I am using Packer and cloud-init to create templates for proxmox. I am so lost and annoyed. Every time I create a template my user is created with a uid and gid 1000 then right after it the Ubuntu user is created with a uid of 1001 and gid 1002. I can’t find this happening to anyone any where. I read the documentation and it says that if a user is defined the Ubuntu user won’t be created. Am I wrong I’ve so many different cloud-configs I can’t count. To make it more annoying every time I try to remove the Ubuntu user with automation after the template is created the next boot the Ubuntu user is right back in there. I am at such a loss. Have stumbled upon a weird bug and I doing something wrong? I’ve gone through the logs like crazy and all it says is the ubuntu user is created it gives no mention as to why.

#cloud-config
autoinstall:
  version: 1
  locale: en_US
  keyboard:
    layout: us
 ssh:
   install-server: true
   allow-pw: true
   disable_root: true
   ssh_quiet_keygen: true
   allow_public_ssh_keys: true
packages:
  - qemu-guest-agent
  - sudo
storage:
  layout:
    name: direct
  swap:
    size: 0
user-data:
  package_upgrade: false
  timezone: (user timezone)
  users:
    - name: (user)
      groups: [adm, sudo]
      lock-passwd: false
      sudo: ALL=(ALL) NOPASSWD:ALL
      shell: /bin/bash
      passwd:(user password)
      ssh_authorized_keys:
        - (user ssh key)
user535733 avatar
cn flag
The behavior you describe does indeed seem contrary to https://cloudinit.readthedocs.io/en/latest/reference/examples.html. Therefore a bug. Please see https://cloudinit.readthedocs.io/en/latest/howto/bugs.html for how to report the bug.
Score:0
bm flag

Also seeing this issue on 22.04.2 iso and packer proxmox v1.1.3.

Ended up just adding an ansible playbook for it to run after as a workaround, sharing here

- name: Remove the user 'ubuntu'
  ansible.builtin.user:
    name: ubuntu
    state: absent
    remove: yes #delete dirs

- name: Remove sudo access for deleted 'ubnt' user
  ansible.builtin.lineinfile:
    path: /etc/sudoers.d/90-cloud-init-users
    state: absent
    search_string: 'ubuntu ALL=(ALL) NOPASSWD:ALL'
    validate: 'visudo -cf %s'


- name: Remove left over config for deleted 'ubnt' user
  ansible.builtin.lineinfile:
    path: /etc/sudoers.d/90-cloud-init-users
    state: absent
    search_string: '# User rules for ubuntu'
    validate: 'visudo -cf %s'
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.