/srv/irclogs.ubuntu.com/2023/10/19/#cloud-init.txt

=== esv_ is now known as esv
dchhttps://www.irccloud.com/pastebin/D07fSXRI/userdata06:37
dchI've tried both sending this at VM invocation, and also manually in `cloud.cfg.d/90_userdata.cfg` and it doesn't seem ever to get started06:38
dchhttps://www.irccloud.com/pastebin/tHfN2nMc/cloud.cfg06:38
dchthis is the cloud.cfg from the same system, which does correctly install its own ssh keys, but my userdata one never gets run06:40
dch`cloud-init schema --system --annotate` says that `Valid cloud-config: user-data` is fine06:40
dchrunning `# cloud-init analyze show` looks like userdata is run, but awfully fast https://www.irccloud.com/pastebin/O5n4kMSo/analyse-show06:41
dchwhich is suspicious06:41
meenadch: morning07:17
* dch waves07:17
meenadch: which part doesn't work? 07:18
dchI can see that the userdata is correctly fetched, `cloud-init query userdata` post boot shows me the expected file07:19
dchbut it doesn't get run07:19
dchI mean, the yaml "commands" in the userdata file aren't executed07:19
meenaI would kill -SIGALRM $RC_PID (or whatever the variable name i documented)07:20
dchmeena: I don't even think it gets that far07:21
dchI replaced that with a simple `touch /var/tmp/bootcmd_was_here` and will re-try07:22
dchnope, nothing happens07:27
dchdagnabdit07:28
dchI can see the userdata being fetched to the appropriate file07:37
dchbut I don't see anywhere userdata being *merged in* to the existing data07:37
dchwhich I would expect to see07:37
dchmaybe this assumption of mine is wrong07:38
dchhttps://www.irccloud.com/pastebin/FpY3A8MZ/setup-datasource-and-consume-user-data07:44
dchthe merged file /var/lib/cloud/instances/11cabbbf-8dd7-446f-91bc-a1ec48b17801/cloud-config.txt appears valid (has the 984 bytes in it)07:46
dchSUCCESS: reading and applying user-data07:47
dchby this point I would expect it to know the new keys/values introduced07:47
dchhttps://www.irccloud.com/pastebin/4hhwWwVb/scripts-user-module07:49
dchall modules run successfully tho07:50
acibaDoes the output of `cloud-init query userdata` contain your user-data?07:54
dchaciba yes it does07:57
acibayou have manually modified `cloud.cfg.d/90_userdata.cfg`, and some modules only run on first boot, did you perform a `cloud-init clean` after rebooting?07:58
acibas/after/before/07:59
dchyes08:00
dchin fact I am now starting from a fresh slate each time08:00
acibaassuming this is your userdata:  https://www.irccloud.com/pastebin/D07fSXRI/userdata, could you please share `/var/log/cloud-init.log` or the output of `cloud-init collect-log`, making sure that any sensitive information is redacted?08:03
acibawhat parts of the userdata are not getting done? write_files, run_cmd ?08:05
dchsure, let me re-summon a box to get a fresh log (I just annihilated the last one)08:08
dchnone of it is run08:08
meenadch: do you have logging enabled08:10
dchyep, always08:10
dchwoop https://usercontent.irccloud-cdn.com/file/o02bSYTv/cloud-init.log08:17
dchaciba: full log 08:18
dchnote it fails the first time through because network isn't up, and then is restarted when network is up08:18
dchthis restart issue is addressed in next release from cloud provider but not yet live08:19
acibaI see08:23
dchI amended userdata slightly, dropping the pkill and just using a touch command08:23
acibacloudinit.sources.DataSourceNotFoundException: Did not find any data source, searched classes: (DataSourceEc2)08:23
dchaciba: right, this is expected the first time around, because there's no network available yet08:24
dchthe next time, it works ok08:24
dchhttps://www.irccloud.com/pastebin/D07fSXRI/userdata has been refreshed08:24
acibathe datasource is not detected because the network is not up, thus the user-data is not pulled08:24
dchand the 2nd run the network is up, the datasource is there, the userdata is fetched, we can see it being merged, 08:25
dch2023-10-19 08:14:45,812 - util.py[DEBUG]: Attempting to load yaml from string of length 1028 with allowed root types (<class 'dict'>,) ...08:25
dch2023-10-19 08:14:45,815 - handlers.py[DEBUG]: finish: init-network/consume-user-data: SUCCESS: reading and applying user-data08:25
dchand checking /var/lib/cloud/instances/bbabee48-2061-41bb-80ee-0c7fbde96f33/cloud-config.txt has the expected data in it08:26
acibain between first and next time, can you perform a `cloud-init clean` ? I think cloud-init does not fully execute your userdata because of the state created on the first boot.08:27
acibaand that second boot logs are not included in the file you shared08:28
dchI can't modify this part its on the vendor side08:28
dchyes the 2nd run is in the log08:29
dchsee e.g. line 21708:29
dch    217 2023-10-19 08:14:43,492 - util.py[DEBUG]: Cloud-init v. 22.4-28-gaecdcbf8 running 'init' at Thu, 19 Oct 2023 08:14:43 +0000. Up 146.85823392868042 seconds.08:30
dchlines 267-~300 show successful metadata fetching08:30
dchso I can cloudinit clean now and re-run08:30
dchv2 run, not fresh boot, but after cloudinit clean & removing stale logs https://www.irccloud.com/pastebin/fPXcz5bB/cloud-init.txt08:32
dchsame thing, userdata actions aren't being run08:33
dchwith latest cloudinit-23.3, same issue (this is 22.4 by default)08:36
dchand as this system has already booted the metadata is returned immediately08:36
dchso we don't have a 2nd run attempt08:36
acibaI see that `Cloud-init v. 22.4-28-gaecdcbf8 running 'modules:final'` is present but there is not an entry corresponding to 'modules:config'.08:38
acibahttps://www.irccloud.com/pastebin/tHfN2nMc/cloud.cfg is interesting, it has fewer modules activated than usually08:39
acibawhat modules do you see when running `cloud-init query combined_cloud_config.cloud_config_modules` and `cloud-init query combined_cloud_config.cloud_final_modules` ?08:41
dchhttps://www.irccloud.com/pastebin/d4HPBHsX/show-modules08:43
acibaThat is the issue, only those modules are allowed to run.08:43
dchaciba: is scripts-user not the thing we need?08:45
dchI had a look this morning already through https://cloudinit.readthedocs.io/en/latest/reference/modules.html but didn't see anythiing different that should be used08:46
acibawhat do you mean by scripts-user ?08:49
acibahttps://canonical-cloud-init.readthedocs-hosted.com/en/latest/explanation/format.html#user-data-script ?08:50
dchaciba: so this has been super helpful. the issue then is that the modules defined in cloud.cfg need to be extended08:50
dchI added `- bootcmd` to cloud.cfg and now the bootcmd section runs08:51
dchwhich is great, but not so important for me08:51
acibasweet!08:51
dchbut we are on the right path08:51
dchI will need to find each failing section, and add them in08:51
dchthis file is inherited from many years ago, from the cloud vendor, and I've honestly not looked at it08:52
acibasounds good, reach out if encounter any problem :)08:53
dchpresumably I can *add* settings via a new `cloud.cfg.d/99_my_stuff.cfg` 08:54
dch🔥08:55
dchlooking great08:55
dch✅ user and groups created08:55
dch✅ bootcmd works08:55
dch✅ write_files works08:55
acibaawesome!08:56
dch✅ sudoers.d08:59
meenadch: who packaged your cloud-init??10:08
dchmeena: literally nobody knows, it was done back on 10.x I think and there isn't anybody left who knows who did it10:10
dchit has been handed down like a sacred scroll, mis-interpreted at each stage until ... today10:11
meenadch:  I would take a look at the current (dev) package config files and diff them. every release i try to improve things, and fix modules10:15
dchmeena: yeah I think the best thing is to dump the existing config file completely and just use the .sample one you provide10:16
dchmeena: does adding packages work in your latest versions?10:18
dch`packages:` "module"10:19
meenathat's been working forever 10:25
meenai don't think i had to even do anything10:25
meenaI would like to break it, by adding multi repo support, but one thing at a time10:25
dchdidn't work here, but then who knows what's borked10:50
dchI don't have ssh_import_id: gh:dch working either10:51
dcheven after merged in all the missing module names from the std install10:51
meenayeah, i think  ssh_import_id is Debian / Ubuntu specific 10:55
dchok so a good haul, finally I am missing:10:56
dch☠️ runcmd, gh:$USER, packages10:57
meenahttps://github.com/canonical/cloud-init/blob/9a401b4a21ea179452143ef8c97f261c1655c539/cloudinit/config/cc_ssh_import_id.py#L2210:57
dchand of those only packages is relevant, and at that, for freebsd, not very important10:57
dchgood to work through these finally10:57
meenaif it's good enough for alpine, it should be good enough for freebsd 10:57
meenahttps://www.freshports.org/security/ssh-import-id/10:58
meenait's just python10:58
meenai can see adding support for that10:59
dch+1 for that10:59
meenait should literally be four lines in four files 10:59
dchI'm calling this a day, thanks meena  and aciba for your endless help and patience10:59
dchgood progress10:59
dchcurl | tee10:59
meenait'd be cool if we had optional dependencies in FreeBSD, but failing that, I think it's no harm adding a single python module with no dependencies 11:00
dchack11:03
dchby the time we add python itself, its already 100mb+11:03
minimalmeena: yeah it wasn't hard adding ssh-import-id for Alpine11:27
meenaminimal: cool, thanks.12:16
meenahrm, i was wrong about no dependencies: New packages to be INSTALLED:12:17
meena        py39-distro: 1.8.0_2 [FreeBSD]12:17
meena        py39-ssh-import-id: 5.11 [FreeBSD]12:17
meenadch: https://github.com/canonical/cloud-init/pull/4533 let's see if netbsd and dragonfly and openbsd also have that package, if so, I'll extend it to those, too.13:20
-ubottu:#cloud-init- Pull 4533 in canonical/cloud-init "cc_ssh_import_id: Extend support to FreeBSD" [Open]13:20
meenai see some discrepancy between distros = ["all"] and "distros": [ALL_DISTROS],14:28
minimalyupe and I believe I mentioned in the past it might make sense to also have ALL_LINUX_DISTROS and ALL_BSD_DISTROS (or similar)14:57
meena*nod*15:02
=== sergiodj_ is now known as sergiodj

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!