=== meena2 is now known as meena [09:29] hi 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 boot [10:44] DanyC: and it didn't believe you… hrm… [10:44] DanyC: cloudinit started on boot? what's /var/run/cloud-init look like? what do the logs say? [10:48] meena: yes cloudinit started on boot. nothing odd in cloud-init.log while in -init-output.log it doesn't show me my user-data script [10:52] DanyC: so what happens when you do a cloud-init clean --logs --reboot now? [10:59] meena: same thing, i don't see any chance in init-output nor in the configuration of the instance. [11:00] DanyC: any chance of/for what? [11:00] oh, change. [11:00] in 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] *change sorry for typo meena [11:00] DanyC: at the very least, your hostname should have been set. [11:06] n.b.: I have been lucky enough to have never worked with AWS. so take everything i say with a bag of salt. [11:06] (i have worked with Salt however) [11:27] DanyC: 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 passed [11:28] ananke: 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 luck [11:44] will 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 packer [11:45] DanyC: what distros are you testing this with? I can check on amazon linux 2, centos 7, & ubuntu 18.04 lts [11:48] ubuntu 16.04 ananke [11:48] didn't that reach EOL last year? [11:49] ahh, nevermind, studio did. 16.04 lts is still in maintenance update phase until 2021 [11:56] ananke: happy to provide the cloud-init version if that helps. [11:57] DanyC: how are you creating those AMIs? packer or some other process? [11:59] ananke: 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 in [12:00] sounds like packer could help you automate that === cpaelzer__ is now known as cpaelzer [13:54] ananke: it could but that won't solve my prob. (there is more tech debt i need to tackle to get it going). [13:57] DanyC: btw, how do you pass your user-data to that new instance? using aws cli, their web console, or something else? [14:00] ananke: 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 simple [14:02] DanyC: and you're using the base64 encoding function right? [14:02] something like: UserData: [14:02] Fn::Base64: !Sub | [14:02] ananke: that is correct, that is what i'm doing [14:03] that'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 creation [15:36] DanyC: Could you file a bug and attach the tarball that `cloud-init collect-logs` creates on an affected instance, please? [15:37] (File a bug at https://bugs.launchpad.net/cloud-init/+filebug :) [16:23] Odd_Bloke: sure thing i can do so [20:04] @rharper I tried your suggestion and it should work in theory, but I get [20:04] type object 'PlatformComponent' has no attribute 'preserve_instance' [20:04] https://paste.ubuntu.com/p/KTSXVh5TRy/ [20:04] ahosmanMSFT: yes, I was going to reply [20:04] you cannot reference a property of the definition [20:04] the object gets an instance in collect where it creates a PlatformComponent [20:05] in collect_snapshot IIRC [20:05] somewhere from the args.preserve_instance where that value is known, we'll need to propigate that through to the platform [20:06] possibly 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 yet [20:06] rharper: I'll target the source then and pull the property from there instead