/srv/irclogs.ubuntu.com/2022/05/14/#cloud-init.txt

hnusHi, I am using multipass which accepts cloud-init and even after hours of trying I am unable to do something which I expect to be simple and common.10:37
hnusI want to run script at stage where everything is set up same as if I used multipass launch and from within launched instance ran the script manually none of `scripts/per-*`, `runcmd` or `cloud-init status --wait && command` work they are all too early. In case of `cloud-init status --wait` I think there is a bug because it waits forever.10:37
hnusTo install my dependency I need to have things like $HOME set up. I admit I am no linux guru but I feel like this shouldn't be this hard no? Almost feel like I am doing something which is not supported or meant to done.10:37
hnusSorry for poorly formatted message I am still getting hang of this irc stuff10:38
holmanbhnus: no worries wrt formatting, that's how I would type it20:14
holmanbhnus: re:  I think there is a bug because it waits forever. < that command will wait until the cloud-init final service is complete. Lots of different things could potentially cause cloud-init to never complete, including kernel bugs, systemd bugs, misconfiguration of any service that cloud-init depends on, cloud-init misconfiguration, etc.20:18
holmanbhnus: also, I assume that you didn't do this but: `cloud-init status --wait` shouldn't be in your runcmd (just mentioning that because I would expect that to never complete, which you mentioned as a symptom)20:21
holmanbhnus: here are the docs for configuring linux users (including $HOME being set up) https://cloudinit.readthedocs.io/en/latest/topics/modules.html#users-and-groups20:25
hnusThe only change I did to default was the `cloud-init status --wait && echo done` but as you now mention it I most probably had it in `runcmd` but I might have also tried the `per-*` scripts I will try again just to confirm using `&& command` with it is ok? Bash is full of footguns so just making sure this is not one of them20:25
holmanbhnus: note the homedir key20:25
holmanbhnus: what exactly do you need to wait for in the boot process? for cloud-init runcmd is as late as it gets20:27
holmanbhnus: yeah you can do && command in your runcmd for conditional execution, though for that you'll want your commands to be strings not lists of strings, because execve() doesn't know what `&&` is20:30
holmanbruncmd args that are lists get passed to execve and strings are executed in a shell, iirc20:31
holmanbhnus: yeah make sure you don't invoke `cloud-init status --wait` from within cloud-init configs themselves - this will deadlock because synchronously waiting for a service to end from within the service itself will never complete20:36
holmanbhnus: lmk if you have more questions, but I need to run now20:36
hnusWell I wanted to have easy access to linux no matter the system I am currently on so I can manage but for now mostly play with my nixos servers multipass is perfect for it as its small terminal only vm image which is also easy to install nix to. My goal was to have script which will boot up vm if you don't yet have it, install nix and drop you into console without any additional dependencies install etc. The thing which gets me almost there is to run `sh20:36
hnus <(curl -L https://nixos.org/nix/install) --no-daemon` when vm is ready but when I managed to run it somehow it complained about $HOME not being set up 20:36
hnusOk I will give it another try and lets see, thank you20:37
holmanbhnus: ah, hold on I think I might see the issue, you're referencing the $HOME environment variable from within the cloud-config?20:38
hnusI guess its needed somewhere in nix install script20:39
hnusit not being available made me to believe I am early running the script20:39
holmanbhnus: that environment variable might not have the value you need it to. (not sure how nixos install script is  using it) Try manually setting it in the same line20:40
hnusit might be something completely different but running the script when vm is fully booted up works20:40
hnusok20:40
holmanbto inspect the environment variables, you  could try something like this in runcmd: env > /root/env-vars.txt20:41
holmanbthen after initialization cat the file and check for HOME20:42
holmanbgood luck with Nix - I know just enough about it to know that I'm not ready for it :)20:43
holmanbokay actually going now, seeya around hnus :)20:43
hnusbye20:44
hnus@holmanb I am learning it out of pure spite now tbh everything people said had steep learning curve like vim and what not were not that bad after bit of time, tons of examples, resources, stable ecosystem and so on. This nix stuff is really something else but I am hoping that it will click one day the ability to have truly reproducible/declarative server management is what makes me going:D20:49

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