Hi!
I have a very strange problem. I’m trying to use containers from ubuntu-minimal: images with cloud init user data
I’ve created a profile for all my cloud-init things:
config:
cloud-init.user-data: |
#cloud-config
locale: C.UTF-8
timezone: Europe/Moscow
runcmd:
- [apt-get, -y, update]
- [apt-get, -y, upgrade]
- [apt, -y, autoremove]
- [touch, /tmp/simos_was_here]
users:
- name: alex
plain_text_passwd: 'foobarbaz'
chpasswd:
expire: True
ssp_pwauth: false
shell: /bin/bash
groups: admin, sudo
ssh_authorized_keys:
- ssh-ed25519 <SSH KEY> <SSH KEY ID>
- name: ansctl
shell: /bin/bash
ssh_authorized_keys:
- ssh-ed25519 <SSH KEY> <SSH KEY ID>
write_files:
- content: |
ansctl ALL=(ALL) NOPASSWD: ALL
path: /etc/sudoers.d/ansctl
owner: root:root
permissions: '0640'
description: General settings for instances
devices: {}
name: cloud_init
When I create a ubuntu-minimal 22 and assign the profile to it with
$ lxc init ubuntu-minimal:22.04 test22
$ lxc profile assign test22 default,cloud_init
$ lxc start test22
After some time I can see that the cloud-init completed sucsessfully:
$ lxc exec test22 bash
root@test22:~# ls -l /tmp
total 2
-rw-r--r-- 1 root root 0 May 31 12:24 simos_was_here
<snip>
root@test22:~# id alex
uid=1000(alex) gid=1000(alex) groups=1000(alex),27(sudo),114(admin)
root@test22:~# id ansctl
uid=1001(ansctl) gid=1001(ansctl) groups=1001(ansctl)
But when I create a container with ubuntu-minimal:20.04 following exactly the same path, cloud-init gets ignored:
$ lxc init ubuntu-minimal:20.04 test20
Creating test20
$ lxc profile assign test20 default,cloud_init
Profiles default,cloud_init applied to test20
$ lxc start test20
$ lxc exec test20 bash
root@test20:~# cloud-init status
status: done
root@test20:~# ls /tmp
systemd-private-1c549f5b4368426d87cc20f20a1ce49b-systemd-hostnamed.service-dXo3vi systemd-private-1c549f5b4368426d87cc20f20a1ce49b-systemd-resolved.service-95Ytah
systemd-private-1c549f5b4368426d87cc20f20a1ce49b-systemd-logind.service-DFDMUh systemd-private-1c549f5b4368426d87cc20f20a1ce49b-systemd-timedated.service-X9gVpi
root@test20:~# id alex
id: ‘alex’: no such user
root@test20:~# id ansctl
id: ‘ansctl’: no such user
root@test20:~#
Am I missing something?
P.S. The same approach with the “full” 20.04/cloud image works, but the container get a lot of unnecessary stuff in it