/srv/irclogs.ubuntu.com/2024/06/02/#cloud-init.txt

norrlandRegarding FreeBSD on cloud. I'm working on providing FreeBSD in our cloud offering. Waiting for the growfs zfs related patch to be released and tested until I can ship the zfs template.13:15
Mister_XHello15:40
Mister_XI'm using cloud-init with 2 custom config files. It runs one of them, but doesn't run the other (and the logs suggest it has read it but that's all).15:41
Mister_XI've validated the file and cloud-init tells me it's ok15:41
minimalwhat exactly do you mean by "2 custom config files"?15:42
Mister_Xfiles that I've written myself15:42
Mister_Xlet me show you15:42
minimalyou'll need to indicate which DataSource you're using (NoCloud?) and provide the configuration and/or logfile to illustrate the problem15:43
Mister_Xhttp://paste.debian.net/1318886/15:44
minimalso you're using the "None" DataSource15:45
minimalso how are you providing the configuration?15:45
Mister_Xyes15:45
Mister_Xand that's the second file: http://paste.debian.net/1318887/15:45
Mister_Xwhat do you mean providing the configuration? I just need it to run the second file15:46
Mister_XI'm using it with debian, and I'm not changing the default config15:46
minimalhow do you expect cloud-init to know about the 2nd file?15:46
Mister_XI've put both of them in /etc/cloud/cloud.cfg.d15:47
Mister_Xthe issue is the second file isn't executed and I'm not sure what I'm doing wrong15:47
minimalindeed where is the 1st file also? generally setting the datasource_list is done in /etc/cloud/cloud.cfg or a file inside /etc/cloud/cloud.cfg.d/ directory15:47
Mister_Xin the same directory15:47
Mister_Xthey're both in /etc/cloud/cloud.cfg.d15:48
Mister_Xthe first one is called 90_nods.cfg, and the second one 99_docker.cfg15:48
Mister_X(just in case, file permission seem good, they both have the same permissions)15:48
minimalthe 2nd file appears to be user-data but generally (or at all?) user-data is not placed in /etc/cloud/cloud.cfg.d/15:48
Mister_Xso, where should I put it?15:49
minimalconfiguration and user-data are 2 different things15:49
minimalyou put the user-data wherever the DataSource you are using expects it15:50
minimalthis differs between DataSources15:50
minimalhmm, the "None" does DO talk about putting user-data in config.cfg or cloud.cfg.d/*. I didn't know that, I've never used None15:51
minimals/does/docs/15:51
Mister_XI'm kinda lost now. I'm running this on an Ubuntu 24.04 (host), and the guest is a debian 12.15:51
Mister_Xcloud-init is on debian1215:52
minimalhowever they refer to specifying user-data there via "userdata_raw"15:52
Mister_XI'm even more lost15:52
minimaldid you read the docs on the None DataSource? https://cloudinit.readthedocs.io/en/latest/reference/datasources/none.html15:52
minimala file beginning "#cloud-config" is a user-data FILE not a cloud-init config file15:53
Mister_XI haven't seen that. I assumed that simply placing the file with runcmd in the directory would make it run it15:54
minimalas I said there is a difference between config files and user-data files15:54
minimalyou're trying to use user-data files in the config directory15:54
minimalyou can embed user-data inside a config file using "userdata_raw:"15:55
Mister_XI merely added the first one to make it stop trying to get metadata15:55
minimalthe 1st file *without* the "#cloud-config" line is a valid config file15:57
minimalcloud-init always uses a DataSource, normally it tries to autodetect which one(s) are available. You can avoid this automatic select by specifying a specific DataSource, which is what you have done to use "None"15:58
Mister_Xso, if I understand correctly the page you linked, my second file should be replaced with http://paste.debian.net/1318889/ ? Should it still be next to the None datasource?15:59
Mister_X(as in the first file)16:00
minimalor you could just have a single file by adding the "datasource_list: [ None ]" line to your new file instead16:01
minimalbut do not put "#cloud-config" in any file in /etc/cloud/cloud.cfg or /etc/cloud/cloud.cfg.d/*16:02
Mister_XI just need the second file to be run once, and then never again. My idea was to delete it at the end. Unless there is a better way to do this16:02
Mister_Xok, thanks16:03
Mister_X(I need to keep the first one)16:03
minimalwell normally meta-data includes an instance-id and as long as this doesn't change then things shouldn't be run more than once16:04
minimalwhy do you need to keep the 1st file?16:04
Mister_Xso that it doesn't keep trying to get the metadata (and keep retrying for a long time) which is delaying boot16:05
minimalso I think you want to add "instance-id: <random value>" to the "metadata:" section of your 2nd file16:06
minimal"so that it doesn't keep trying to get the metadata" - why doesn't putting the datasources_list entry into the 2nd file INSTEAD not resolve this?16:06
Mister_Xit feels like it's better to keep things separate, as I'm doing 2 different things: stop getting metadata, and running a few commands16:09
Mister_XSo, here is the resulting 2nd file: http://paste.debian.net/1318890/16:09
minimalI guess that instance-id value is valid, I can't find any docs on its format, normally it is a UUID16:13
minimaldid you remove the "#cloud-config" line from the 1st file?16:13
Mister_Xyes. However, validating the second file tells me it's missing the #cloud-config at the top16:14
minimalwhat exact command are you using to validate?16:16
Mister_Xcloud-init schema --config-file ${filename}16:17
minimalthat only supports validating either cloud-config (i.e. user-data) network-config files16:17
minimalfiles in /etc/cloud/ are NOT cloud-config or network-config files16:18
minimal"cloud-init schema" currently does not support validating configuration files16:18
Mister_Xsince you're saying user data shouldn't be in /etc/cloud. Where should it ideally be?16:19
Mister_XI mean, where does cloud-init expects it?16:19
minimalthat depends on the particular DataSource16:19
minimalthe same for meta-data and network-config also16:20
Mister_Xin the case of None, it expects it as a raw string in a file in /etc/cloud/cloud.cfg.d?16:21
minimalisn't that what the docs for None say?16:21
Mister_Xyes, I just wanted to confirm I understand correctly16:21
Mister_XI'm completely new to cloud-init16:21
minimalwhat are you running the VM with cloud-init on?16:22
minimali.e. using libvirt/virtd? qemu command-line? ProxMox? some other hypervisor?16:22
Mister_Xlibvirt16:23
Mister_XI'm using an ubuntu 24.04 for now16:23
Mister_Xwith libvirt16:23
minimalnormally I'd expect you would use the NoCloud DataSource rather than None16:23
Mister_XI'm using a debian preseed to configure the VM, and cloud-init to pull docker stuff16:23
minimaland I believe libvirt supports NoCloud16:23
Mister_XNoCloud, if I understand correctly expects a web server, doesn't it?16:24
minimalno16:24
minimaltypically it expects a ISO or filesystem containing YAML files for meta-data, user-data, and optionally network-config16:24
minimalhttps://blog.oddbit.com/post/2015-03-10-booting-cloud-images-with-libv/16:25
Mister_XI'm using virt-install at this time16:27
Mister_Xto install the system with a preseed. In the example, they're importing an existing cloud image16:27
Mister_Xthat will be useful when I'll try the cloud images16:28
minimalhttps://sumit-ghosh.com/posts/create-vm-using-libvirt-cloud-images-cloud-init/16:28
minimalnormally you use cloud-init with a pre-existing image (i.e. that has cloud-init already installed)16:29
minimalso why don't you use the stack Debian cloud-images and provide a NoCloud ISO containing your runcmd as part of the user-data?16:32
minimals/stack/standard/16:32
Mister_XI had started using a preseed, and needed cloud-init to get docker stuff16:36
Mister_XI've tried running docker in the preseed but it's too limited. I could get everything mounted (cgroups, procfs, but it still failed due to networking issues and I couldn't find a solution16:37
Mister_Xso I decided to use cloud-init to do that part16:37
Mister_Xonce the system rebooted16:37
Mister_Xthanks for the resources btw16:38
minimalisn't cloud-init a bit of overkill for that? you could just create a shell script to be run on first boot via systemd to do that16:55
Mister_Xseems like it. It sounded like a good idea until I ran into issues.17:32
Mister_XEven with the modified file as I showed you, it's not running it17:32
Mister_Xand there is nothing in the log file that say why17:33
minimalMister_X: perhaps if you provided a logfile (via a pastebin or equivalent) that might help diagnose things17:38
Mister_Xhttp://paste.debian.net/1318900/ (cloud-init.log) and http://paste.debian.net/1318901/ (cloud-init-output.log)17:51
minimalMister_X: did you see the WARNING in the logfile?17:57
minimalah, I see it also appeared on console (from cloud-init-output.log) also17:59
Mister_XSo I guess instead of putting None in the datasource in the first file, I could put nothing18:00
Mister_Xbut that still doesn't explain why the second file isn't run despite being read18:01
minimalI'm not sure. That output does saw to file a bug...18:01
minimalalso you logfile seems incomplete - this is from cloud-init running automatically during boot?18:01
Mister_Xyes18:01
Mister_Xit's complete, it's the whole thing18:02
Mister_Xunless cloud-init truncated the file18:02
Mister_Xbut I gave the full files18:02
minimalit only shows "init-local" and "init" running, I'd expect to also see "modules:config" and "modules:final"18:04
minimalare there "cloud_config_modules:" and "cloud_final_modules:" lines in either /etc/cloud/cloud.cfg or some file in /etc/cloud/cloud.cfg.d/*18:05
Mister_XLet me paste that file and the list of files inside that directory18:06
Mister_Xhttp://paste.debian.net/1318905/18:07
minimalok, they're there as expected. So all I can assume is that some of the cloud-init systemd services have not been enabled...18:08
Mister_Xhttp://paste.debian.net/1318906/18:09
Mister_Xif the service hasn't been enabled, then how did it start at boot?18:09
minimalI said services, plural18:09
minimalthere are multiple services18:09
minimalso I guessing that the cloud-config.service and cloud-final.service have not been enabled18:11
Mister_Xthey are: http://paste.debian.net/1318907/18:14
minimalthen I'd expect to see their output in cloud-init.log18:14
Mister_Xis there any way to debug why that didn't happen?18:15
minimalcloud-config.server is what would handle the "runcmd" in your user-data so as that service isn't apparently being run (correctly) then that explains why your runcmd commands don't execute18:15
Mister_Xwould you like a copy of the preseed file and virt-install command so you can reproduce?18:16
minimalnope, I don't use libvirt here18:16
minimalcheck the cloud-config.service perhaps?18:17
Mister_Xhttp://paste.debian.net/1318908/18:18
Mister_Xshould I file a bug report?18:19
minimalwell you should 1st work out why the service doesn't appear to run cloud-init - it would be a cloud-init bug if cloud-init was being run but having problems18:21
minimalcheck the systemd journal etc to see why systemd does not appear to run the cloud-init "config" and "final" stages18:21
Mister_Xhow would I do that? I checked journalctl, and there are no logs for either of them18:23
Mister_XI grepped the logs for the whole journalctl to find cloud stuff, and there is nothing18:24
minimalthat's systemd diagnosis/debugging, not specific to cloud-init18:24
Mister_Xdo you have any pointed to the docs about that part?18:24
minimalsystemd docs/manpages? lol18:24
Mister_XI knew that, but I was wondering if you knew already where to look18:27
minimalI don't use systemd as my usual init system...18:27
minimalbasically if the cloud-config.server runs cloud-init ok then I'd expect to see more lines at the end of the cloud-init.log you provided, beginning with "util.py[DEBUG]: Cloud-init v. 22.4.2 running 'modules:config' at ..."18:30
minimals/server/service/18:30
minimalso it could be an issue with the cloud-config.service, or on one of the other things it depends on/runs after such as network-online.target and cloud-config. or snapd.seeded.servicetarget18:32
minimals/cloud-config. /cloud-config.target/18:33

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