/srv/irclogs.ubuntu.com/2016/11/15/#cloud-init.txt

aisraelI want to execute a post-initiation piece of user-data. I tried adding the data to /var/lib/cloud-scripts/per-boot but the script fails. What should that script look like?15:17
rharperhttp://cloudinit.readthedocs.io/en/latest/topics/examples.html#run-commands-on-first-boot15:24
aisraelrharper: I tried that, but seeing an error in cloud-init.log. Here's the script: http://pastebin.ubuntu.com/23480882/15:30
aisraeland the relevant log: http://pastebin.ubuntu.com/23480880/15:31
rharperaisrael: and the first paste is the contents of that 99-test ?15:33
aisraelrharper: Correct15:33
smoserwell, it says:15:33
smoser ['/var/lib/cloud/scripts/per-boot/99-test']#012Exit code: -#012Reason: [Errno 8] Exec format error#012Stdout: ''#012Stderr: ''15:33
smoseroh. yeah. so aisrael if you want to just execute something per boot15:33
smoserthe things in that dir need to be executable15:34
smoserthey're things to execute, not cloud-config15:34
rharperaisrael: if you use runcmd, it's exec directly from cloud-init.   vs.  adding a file to that dir15:34
rharperwhat I suggested is different than writing files to per-boot dir15:34
aisraelsmoser: Is there a way to run a bit of cloud-config on every boot? For background, I'm writing a cloud-init charm layer, where the underlying machine has been pre-allocated (think manual provider)15:36
smoseryou can change the runcmd to run every boot. the thing that stinks about doing that is that you have to re-define all of 'cloud_final_modules' (see /etc/cloud/cloud.cfg) in order to modify the frequency of scripts-user15:38
aisraelsmoser: ok, supposing I did that ([scripts-user, always]), would I then put that cloud-config into /etc/cloud/cloud.cfg.d?15:40
smoserhttp://paste.ubuntu.com/23480925/15:40
smoseryou can put it in user-data, or you can modify the file in /etc/cloud/cloud.cfg or add it to a file in that dir.15:41
rharperaisrael: fwiw, your examine with runcmd works fine on a new instance; I think your failure was related to the modifications of files in the local per-boot dir15:41
smoserright.15:42
smoseraisrael, you can also use write_files to put something into /var/lib/cloud-scripts/per-boot15:42
smoserand that thing that you write there will run once per boot15:42
rharperthat seems best15:43
smoseraisrael, http://cloudinit.readthedocs.io/en/latest/topics/modules.html#write-files15:44
aisraelOk, let me see if I can get this working via cloud.cfg. It's not writing files, per se, that I need but to inject custom cloud-config into an already bootstrapped instance.15:48
smoseraisrael, oh. well, that will be more difficult.15:50
aisraelsmoser: rharper: Thanks for the info!  I'm not sure what my path forward on this will be, but I have a clearer idea now.16:08
smoseraisrael, you can 'cloud-init single --frequency=always --name=<that-name>'16:09
smoserbut you have to know what that-name is. ie, which cloud-initmodules will need tob e run for your config.16:09
aisraelsmoser: ok, that makes sense16:10
smoserrharper,19:14
smoserhttp://pad.ubuntu.com/tMdgYGEvgL19:14
smoserlook at the bold19:14
* rharper looks19:14
smoseri'm not sure if we want Before=basic.target there.19:14
smoserversus before=sysinit.target19:15
rharperhrm19:15
rharperlemme look at my yakkety instance19:15
smoserpitti reviewed that and acked it at https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+merge/31054719:15
rharperyou have Before=basic.target twice19:16
rharperline 24 and 26/2719:16
rharperhttp://paste.ubuntu.com/23481950/19:18
rharpersmoser: I think looking at that, basic.target is too late19:18
smoserrharper, its not twice. where do you see that ?19:19
rharperI mentioned the lines19:19
rharper - add Before=basic.target (**wonder if this is right**)19:20
rharper- add Before=basic.target19:20
rharper      this is done to become part of "early boot" in order to to be able to affect mounts (http://pad.lv/1611074)19:20
smoseroh. in the pad.19:20
rharperyes19:20
rharpersorry19:20
smoseri thought you mean tin the .service19:21
smoseradjusted the pad19:21
rharperso, the -replace 'Wants'/After local-fs.target with 'systemd-remounte-fs.service' is much earlier19:21
rharperif local-fs.target is good enough? why would we wait longer ?19:21
smoserwe dont wait longer.19:22
smoserwe are now running earlier (possibly)19:22
smoserafter local-fs.target would possibly include all the local systemd generated .mount19:22
smoserwhich we have to run before19:23
smoseri think its right.19:24
rharpersmoser: so, Xenial without the SRU is running *too late* for mount;  what did we put in Yakkety ? Before=local-fs.target ? and slangasek suggests systemd-remount-fs.service ?19:25
smoserslangasek saw what he believed was a loop19:26
rharpersmoser: I'm confused between what we did in yakkety, vs. where Xenial is at (I'm ignoreing where Xenial is at, and interested in changes to cloud-init trunk to understand the changes; then we can look at the Xenial -> SRU changes19:26
smoserbut not one i'd seen in practice.19:26
* rharper looks a this cloud-init-loca.service now19:26
smosersure. thats fine. thats ultimately what we're doing.19:26
rharperthe Wants=local-fs.target with an After=local-fs.target19:26
rharperis what we have in yakkety now19:27
rharperfor cloud-init-local.service19:27
rharperthat *functions* for early mount19:27
rharperand slangasek suggests that makes a loop or something like that ?19:27
smoserright.19:27
smoserwell, he did.19:27
rharperIm not seeing it either19:27
smoserwhich is why i dropped the local-fs stuff19:28
smoseri'm not sure it is or not19:28
smoserbut essentially saying : After=local-fs.target19:28
smoser*and*19:28
rharperit seems we need a Before=sysinit.target *AND* a After=systemd-remount-fs.service19:28
rharpermaybe that RequiresMountsFor does the trick19:28
smoserno.19:28
smosershoot.19:28
smoserso... we drop the local-fs.target19:29
smoseras we dont need that and because we're writing things to /etc/fstab, it seems like there could be a loop there.19:29
smoseras we say that those mounts should not be processed untill after cloud-init.service19:29
rharperahh19:30
rharperI see19:30
smoserbut we said cloud-init.service should be after local-fs.target (which would include them)19:30
smoserit seems reasonable19:30
rharperyes19:30
smoserbut i'd never seen it19:30
rharperoddly neither have I19:30
rharperand there's no complains19:30
smoserno 'break's or complaints or anything19:30
rharpercomplaints from journalctl19:30
rharperright19:30
smoserso i suspect that sytemd resolved it elsewhere19:30
smoserprobably by adjusting the .mount things19:30
rharperwell19:30
rharperclearly from the chain, local-fs.target is *reached* prior to cloud-init-local running19:30
rharperand trivially cloud-init.service19:31
smoseri assume it changed the meaning of local-fs.target19:31
rharperso it must not be a hard requirement w.r.t fstab writing19:31
smoserso at the moment i think that Before=basic.target is ok,19:31
smoserat least i dont have any fallout of that that i'm aware of19:32
rharperit's clearly OK, as basic.target is much later19:32
smoseri think i'll prepare sru with it as it is in zesty19:32
rharperthe question is whether we want to ensure we run even earlier19:32
smosermuch later than waht ?19:32
rharpersay Before=sysinit.target19:32
rharperor local-fs.target19:32
smoseryeah, so i suspect that cloud-init.services 'Before=basic.target' ends up not doing anything19:33
rharpersmoser: so, I think we have to be after local-fs.target in that, we can't assume we can write to /etc/fstab unless we have local-fs.target, right ?19:33
smosershoot19:33
smoseryeah, so i suspect that cloud-init-local.service  'Before=basic.target' ends up not doing anything19:33
smoseras cloud-init.service is Before=sysinit.target and After=cloud-init-local.service19:34
rharperwell, it's before it, but that's not really making it run "early"19:34
smoserso cloud-init-local.service gets forced early due to cloud-init.service's Before=sysinit.target19:34
smoserso i think this is fine.19:34
rharpersmoser: we might want to do an in HO with slangasek in a bit19:38
smoser:)19:38
jgrimm+119:38
rharperI think cloud-init-local.service should be explicit19:38
smoserrharper, yes, we should change it , but it does not actually change anything19:46
smoseradded https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+merge/31091919:46
rharpersmoser: yes19:48
powersjsmoser: ping re: set_hostname vs change_hostname20:44
powersjerr s/change/update/20:44
smoserpowersj, thinking20:44
smoserok. so20:46
smoserupdate_hostname runs PER_ALWAYS (every boot)20:46
smoser(more coming)20:46
smoserpowersj, http://pad.ubuntu.com/NtJAvEJEiJ21:03
powersjsmoser: thank you. Let me think about that and implications with testing them21:07
powersjharlowja: around? question re: cc_ssh_authkey_fingerprints21:43
smoserrharper, http://paste.ubuntu.com/23482707/22:11
smoserdoes that seems right ?22:11
rharpersystemd-networkd.service is After dbus.target should say After=dbus.service22:11
rharperand sysinit.target is before dbus.service; hence the loop22:12
rharperdbus.service which runs after sysinit.target, but cloud-init.service is Before=sysinit.target22:13
rharpersmoser: and the last paragraph is spot-on22:13
smoserrharper, fixing22:15
* rharper relocates home22:31
vans163question. Does cloud-init automatically resize the root partition to the size of the image?  Say i download a cloud image that is 2gb max size, i do qemu-img resize img.img 50G, making it 50G now, when it first boots using the cloud-init iso will the root partition autoresize to 50G/22:46
powersjvans163: I think so... take a look at https://cloudinit.readthedocs.io/en/latest/topics/modules.html#resizefs23:00
vans163powersj: ty guessing default may not be true23:04
smoservans163, yes.23:54
smoserwas it not doing that ?23:54
smoseryou can tell it not to. but generally thats the desired behavior23:55

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