/srv/irclogs.ubuntu.com/2020/02/10/#cloud-init.txt

=== meena2 is now known as meena
DanyChi all, anyone has any tips/ thoughts as to why cloud-init wouldn't run on a new EC2 instance created from an AMI which was created from a running EC2 instance? Pls not before creating the image i've run "cloud-init clean" to let cloud-init know/ think that is a first boot09:29
meenaDanyC: and it didn't believe you… hrm…10:44
meenaDanyC: cloudinit started on boot? what's /var/run/cloud-init look like? what do the logs say?10:44
DanyCmeena: yes cloudinit started on boot. nothing odd in cloud-init.log while in -init-output.log it doesn't show me my user-data script10:48
meenaDanyC: so what happens when you do a cloud-init clean --logs --reboot now?10:52
DanyCmeena: same thing, i don't see any chance in init-output nor in the configuration of the instance.10:59
meenaDanyC: any chance of/for what?11:00
meenaoh, change.11:00
DanyCin short i have the same issue described (maybe better than me here) at https://www.reddit.com/r/aws/comments/bwfvtz/when_does_user_data_run_in_ec2_instances_whose/11:00
DanyC*change sorry for typo meena11:00
meenaDanyC: at the very least, your hostname should have been set.11:00
meenan.b.: I have been lucky enough to have never worked with AWS. so take everything i say with a bag of salt.11:06
meena(i have worked with Salt however)11:06
anankeDanyC: interesting, I'll have to test this when I get to the office. I'm working now on a project involving that exact scenario: creating new AMIs from existing ones with packer. cloud-init does run in the results, but I haven't tested if user-data can be passed11:27
DanyCananke: let me know your findings. Is a bit hit and miss on my side: as 2 our of 10 works. I've even tried to set/ do https://aws.amazon.com/premiumsupport/knowledge-center/execute-user-data-ec2/ but no luck11:28
anankewill do. I'll be in the office in a couple of hours, and I'll get to that first. this potentially means I'll have to bake in some cloud-init cleanup at the end of baking the image with packer11:44
anankeDanyC: what distros are you testing this with? I can check on amazon linux 2, centos 7, & ubuntu 18.04 lts11:45
DanyCubuntu 16.04 ananke11:48
anankedidn't that reach EOL last year?11:48
anankeahh, nevermind, studio did. 16.04 lts is still in maintenance update phase until 202111:49
DanyCananke: happy to provide the cloud-init version if that helps.11:56
anankeDanyC: how are you creating those AMIs? packer or some other process?11:57
DanyCananke: custom, i create a vmdk from an iso using qemu and then import the main AMI. Then at T1 create new instance from the main AMI (cloud-init user data kicks in), do some manual config, run "cloud-init clean", then create image from the running EC2 (w/o reboot btw).  Then at T2 i create a new EC2 from the snapshotted AMI, userdata doesn't kick in11:59
anankesounds like packer could help you automate that12:00
=== cpaelzer__ is now known as cpaelzer
DanyCananke: it could but that won't solve my prob. (there is more tech debt i need to tackle to get it going).13:54
anankeDanyC: btw, how do you pass your user-data to that new instance? using aws cli, their web console, or something else?13:57
DanyCananke: through cfn, creating a basic EC2 instance and passing a bash script to it. Note i'm not using cfn-hup/ cfn-init etc, keep it dead simple14:00
anankeDanyC: and you're using the base64 encoding function right?14:02
anankesomething like:       UserData:14:02
ananke        Fn::Base64: !Sub |14:02
DanyCananke: that is correct, that is what i'm doing14:02
anankethat's actually on my to-do list this week, to have a new cloud formation template for testing the AMIs I create, including sending user-data. right now I just have the cloudformation template surrounding the packer creation14:03
Odd_BlokeDanyC: Could you file a bug and attach the tarball that `cloud-init collect-logs` creates on an affected instance, please?15:36
Odd_Bloke(File a bug at https://bugs.launchpad.net/cloud-init/+filebug :)15:37
DanyCOdd_Bloke: sure thing i can do so16:23
ahosmanMSFT@rharper I tried your suggestion and it should work in theory, but I get20:04
ahosmanMSFTtype object 'PlatformComponent' has no attribute 'preserve_instance'20:04
ahosmanMSFThttps://paste.ubuntu.com/p/KTSXVh5TRy/20:04
rharperahosmanMSFT: yes, I was going to reply20:04
rharperyou cannot reference a property of the definition20:04
rharperthe object gets an instance in collect where it creates a PlatformComponent20:04
rharperin collect_snapshot IIRC20:05
rharpersomewhere from the args.preserve_instance where that value is known, we'll need to propigate that through to the platform20:05
rharperpossibly through the instance constructor; I was thinking it could be set in the config which is passed into the Image creation, but I'm not quite sure yet20:06
ahosmanMSFTrharper: I'll target the source then and pull the property from there instead20:06

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