[15:51] <DP21> Hi all. If you don't mind have a question regarding cloud-init + AWS + vendor data. I am trying to add custom configuration to the new Amazon Linux 2023 AMI that uses cloud-init 22.2. The case is absolutely the same as in the bug https://bugs.launchpad.net/cloud-init/+bug/1913461 that should have been fixed in version 22.4, but AWS doesn't have
[15:51] <DP21> that version and I guess won't have it for a while because Amazon linux 2023 uses python3.9.
[15:51] <DP21> In short the case is the following:
[15:51] <DP21> 1. We create custom image based on Amazon Linux 2023
[15:51] -ubottu:#cloud-init- Launchpad bug 1913461 in cloud-init "Need jinja templating in config files" [Wishlist, Fix Released]
[15:51] <DP21> 2. We can't use user-data to the customization, because that will be done by users of the AMI
[15:51] <DP21> 3. So, the best way to add these customization is to use /etc/cloud/cloud.cfg.d/ config file, BUT in the version of cloud-init that we have we can't use jijna placeholders for the Datasource to get meta-data
[15:51] <DP21> 4. At the same time we can't upgrade cloud-init to the latest version
[15:51] <DP21> I want to clarify the possibility to use vendor data in the AWS environment. Is there any way or example how to supply vendor data to AWS instance? Maybe there is a way to put them locally?
[15:51] <DP21> Thanks,
[15:56] <falcojr> DP21: unfortunately, vendor data can only be provided by the vendor, which in this case is EC2. It would get fetched directly from their metadata service and not something that can be simulated locally
[15:57] <falcojr> if you're creating a custom image, is there a reason you can't upgrade cloud-init within that image? 22.4 works on python 3.9
[16:27] <meena> docs Bug? https://github.com/canonical/cloud-init/issues/4229
[16:27] -ubottu:#cloud-init- Issue 4229 in canonical/cloud-init "Broken link to the hacking document" [Open]
[16:28] <DP21> falcojr  thanks for the reply. That was my guess. As for the upgrade of cloud-init:
[16:28] <DP21> 1. I am not sure what customizations has AWS added to their build of cloud-init (if any) and what issue that can cause in future
[16:28] <DP21> 2. I was surprised not to found RPM for that particular version of cloud-init. For example at https://rpmfind.net/linux/rpm2html/search.php?query=cloud-init it looks like Fedora (base of Amazon Linux 2023) have skipped versions 22.3 and 22.4.
[16:28] <DP21> But yeah, maybe to build custom rpm is the way
[16:29] <damjan> hi all, I have cloud-init with: mounts: [ [ /dev/sda2, /mnt ], [ /dev/sda1, /mnt/efi ] ], and cloud-init creates the proper fstab our of that config, and then calls `mount -a`. alas, mount -a fails since the /mnt/efi mount point does not exist.
[16:30] <damjan> one solution would be to call for ex. `systemctl start mnt-efi.mount` (for each new mount, instead of mount -a) since that also makes sure the target mountpoint exists
[16:31] <damjan> should I propose a PR on github?
[16:31] <damjan> or is there a better solution
[16:31] <damjan> … the usage of systemctl, would of course be conditional on systemd
[16:32] <minimal> damjan: why does /mnt/efi i not exist?
[16:33] <damjan> minimal: both sda2 and sda1 are empty FSs just created by fs_setup:
[16:33] <minimal> minimal: that doesn't indicate though why a mount of /mnt/efi fails however...
[16:34] <minimal> can you pastebin (or similar) your user-data?
[16:34] <damjan> minimal: `mount -a` doesn't know to create the mount point /mnt/efi
[16:34] <damjan> minimal: sure, https://github.com/gdamjan/archvm-auto-install/blob/main/imds/user-data
[16:39] <minimal> I've never had that sort of problem before with disk_setup/fs_setup/mount
[16:44] <minimal> damjan: let me spin up a VM with similar config that I have used
[16:46] <damjan> ah I see what happens. /mnt/efi is created, BUT then /dev/sda2 is mounted over /mnt so now that's hidden
[16:46] <minimal> damjan: yeah I saw about to suggest that lol
[16:47] <minimal> does /dev/sda2 appear before /dev/sda1 in the /etc/fstab?
[16:47] <damjan> yes
[16:47] <minimal> so I'd expect it to mounted first
[16:47] <damjan> it is
[16:48] <damjan> but the code is a bit weird. I think it creates the targets dir before it tries to mount anything
[16:48] <minimal> oh, right, I thought you meant "mount -a" was doing them in wrong order
[16:49] <damjan> here's the log file https://paste.rs/TTyT7
[16:49] <minimal> rather it is that cc_mounts is creating /mnt/efi dir before /mnt is mounted? yeah I don't think it is smart enough to cater for that
[16:55] <minimal> damjan: this seems to create each mountpoint dir if it doesn't exist: https://github.com/canonical/cloud-init/blob/main/cloudinit/config/cc_mounts.py#L575
[16:56] <minimal> however it is before any "mount -a": https://github.com/canonical/cloud-init/blob/main/cloudinit/config/cc_mounts.py#L582
[16:57] <minimal> and https://github.com/canonical/cloud-init/blob/main/cloudinit/config/cc_mounts.py#L606
[16:58] <damjan> yeah
[17:00] <damjan> do you have an idea what the best approach would be in solving the issue?
[17:21] <minimal> damjan: do the mounts via runcmd instead? (including "rmdir /mnt/efi" before mounting /mnt and "mkdir /mnt/efi" after mounting /mnt)
[17:23] <damjan> yeah I can do that :)
[17:59] <damjan> hm, perhaps cloud-init can use the X-mount.mkdir option
[18:04] <damjan> and forgo its own `mkdir`s
[18:04] <minimal> damjan: that would probably not be supported by BSD and also some Linux distros like Alpine that use Busybox mount
[18:06] <damjan> hey wait, I can add that as the 4th param to mounts:
[18:06] <damjan> minimal: indeed
[18:08] <minimal> I'm going to add a note to the cc_mounts docs about the mount-inside-another-mount issue
[18:09] <damjan> you can mention the `X-mount.mkdir option` for util-linux distros
[18:12] <minimal> ok
[18:59] <damjan> ps. I did test it, and it works, https://github.com/gdamjan/archvm-auto-install/blob/main/imds/user-data#L26
[19:10] <damjan> alas, I might switch to a script that does explicit sfdisk, it gives me more control on the partitioning
[19:16] <minimal> damjan: for GPT partitions cc_disk_setup is (from memory) using sgdisk not sfdisk
[19:17] <damjan> but it only gives me option for partition size in percentages
[19:18] <minimal> not disputing that, just pointing out that sfdisk is used by it for MBR/BIOS and sgdisk for GPT
[19:19] <meena> does anything still use MBR?
[19:21] <minimal> meena: BIOS-only systems, also people who want to create non-boot MBR partitioned disks (i.e. less than 2TB) for whatever reason
[19:22] <minimal> I can create a VM with a 2nd disk of 1TB and then decide whether I want it MBR/BIOS or GPT partitioned, either is perfectly valid to do
[19:25] <damjan> sfdisk can do gpt these days, so it's fine
[19:42] <DP21> falcojr Once again thanks for the answer. I built rpm for Amazon Linux 2023 of version 22.4 and can confirm that jinja templates work for cfg files. Also just for the history rpm build on Amazon Linux 2023 fails because fix for the "udev/rules.d" path inside setup.py for Redhat doesn't work properly. AmazonLinux 2023 doesn't have file
[19:42] <DP21> "/etc/redhat-release" that is used to determinate Redhat family for that particular fix. Below is part of setup.py code
[19:42] <DP21> ```
[19:42] <DP21> if not platform.system().endswith("BSD"):
[19:42] <DP21>     RULES_PATH = LIB
[19:42] <DP21>     if os.path.isfile("/etc/redhat-release"):
[19:42] <DP21>         RULES_PATH = "/usr/lib"
[19:42] <DP21>     data_files.extend(
[19:42] <DP21>         [
[19:42] <DP21>             (
[19:42] <DP21>                 ETC + "/NetworkManager/dispatcher.d/",
[19:42] <DP21>                 ["tools/hook-network-manager"],
[19:42] <DP21>             ),
[19:42] <DP21>             (ETC + "/dhcp/dhclient-exit-hooks.d/", ["tools/hook-dhclient"]),
[19:42] <DP21>             (RULES_PATH + "/udev/rules.d", [f for f in glob("udev/*.rules")]),
[19:42] <DP21>             (
[19:42] <DP21>                 ETC + "/systemd/system/sshd-keygen@.service.d/",
[19:42] <DP21>                 ["systemd/disable-sshd-keygen-if-cloud-init-active.conf"],
[19:43] <falcojr> DP21: for multi-line pastes, please use a pastebin service
[19:43] <falcojr> paste.ubuntu.com is one
[19:43] <DP21> got it
[19:49] <meena> minimal: I'm too poor / broke to have ever seen a 2 TB disk 
[20:19] <minimal> meena: not even a virtual one? lol
[20:46] <damjan> right, easy `qemu-img create -f qcow2 arch-vm.img 20T` :D
[20:48] <meena> minimal: nope 
[20:49] <meena> damjan: will i be able to actually fill that on my laptop with 400? G disk space?
[20:50] <minimal> virtually fill it, yupe ;-)