[13:38] <smoser> Odd_Bloke: can you point c-i at https://code.launchpad.net/~ruansx/cloud-init/+git/cloud-init/+merge/372445
[13:38] <smoser> or paride ^
[13:39] <paride> smoser, looking
[13:52] <paride> smoser, PASSED
[15:03] <bit48> Hi everyone.
[15:06] <bit48> I have what seems to a cloud-init related problem. I have an ubuntu server image I've created for the raspberry pi. It consists of the base ubuntu-server with a few additional scripts and modifications. Now I'd like to make copies of the original image to put in several raspberry pi devices... the problem is that the other PIs don't bring up their
[15:06] <bit48> NICs on boot since the mac configured in netplan is the mac of the first raspberry pi I created the image on.
[15:07] <bit48> where can I find an explanation on how cloud-init creates the netplan yaml?
[15:08] <bit48> and what to do to make it regenerate it?
[15:10] <rharper> bit48: hi
[15:11] <rharper> do you know what datasource you're providing to cloud-init ?  for Pi I suspect it's a no-cloud datasource ?
[15:14] <bit48> I think it is. There's a file /etc/cloud/cloud.cfg.d/99-fake_cloud.cfg with a single line "datasouce_list: [ NoCloud, None ]"
[15:15] <bit48> This is my first time dealing with netplan and cloud-init. Last time I did something similar, ubuntu still had /etc/network/interfaces
[15:18] <rharper> bit48: ok, so I think if you use cloud-init clean --logs on your "master" image before capturing then things will work the way you want
[15:19] <rharper> this will remove the /var/lib/cloud/instance and other files that indicate cloud-init has booted before;
[15:19] <rharper> cloud-init will generate a /etc/netplan/50-cloud-init.yaml at boot time
[15:20] <bit48> That's great.
[15:22] <bit48> No, wait. That's not great. I took a look at /var/lib/cloud. It looks like it might revert some of the changes I've made to the master image - like the removal of the default "ubuntu" user
[15:35] <rharper> bit48: clean won't revert any changes
[15:36] <rharper> it just removes files that cloud-init uses to track what it did
[15:36] <rharper> in some cases like the ubuntu user, cloud-init checks if it's added a user and won't fail if it's already added
[15:36] <rharper> you can disable the default user creation if you want
[15:39] <bit48> Yeah, I'm going to have to remove the creation of the ubuntu user. It's a user I've deleted from the master image. Is the user creation "script" the user-data file at /var/lib/cloud/seed/ ?
[15:40] <rharper> no, the ubuntu user is created by default, you would update the user-data file in /var/lib/cloud/seed/nocloud/user-data
[15:40] <bit48> So if I remove that file, then it won't be created, right?
[15:41] <bit48> (my master image already comes with a different user)
[15:53] <rharper> bit48: let me look a bit;   I do know you can modify /etc/cloud/cloud.cfg to replace the default user (from ubuntu) to whatever you wanted to setup;  that might be easier than disabling the user-creation;
[15:58] <rharper> bit48: alternatively,  in you master image, you could modify the netplan config to change from a match by mac address to a match by name;   https://netplan.io/examples#configuring-a-loopback-interface  ;    and it accepts wildcards for glob matching, so you could have match: name: eth*  or match: name: en* etc.
[16:00] <bit48> thanks
[16:00] <bit48> Why wouldn't deleting the file or commenting out the user creation work?
[16:20] <smoser> ~
[16:30] <rharper> bit48: I'm not sure of the contents of your seed, so I can't be sure; however, cloud-init creates a distro user by default, without any supplied cloud-config/user-data.  So there's nothing to delete/comment out.
[16:31] <bit48> Yeah, deleting the user-data doesn't help. Changing the ubuntu username to the user I want caused cloudinit to reset my password to "ubuntu" :-\
[16:32] <bit48> the user-data is trivial passowrd:ubuntu chpasswd: ubuntu ssh_pwauth:True
[16:33] <bit48> So the way I see it, I have a few options:
[16:35] <bit48> 1. change the mac manually on every image. 2. change the match clause to something other than the mac and hope it works on all devices. 3. change the cloud init configuration to it'll create the user I want instead of the default one, then run cloud-init clean.
[16:46] <rharper> bit48: yeah, I think including user-data that creates the user you want instead of the default user is likely best, with a clean;  cloud-init handles other things like ensuring you have unique ssh host keys;
[17:25] <bit48> I see. Where can I find some documentation about user creation? The best source I found was in the cloud config examples (https://cloudinit.readthedocs.io/en/latest/topics/examples.html)
[17:25] <powersj> https://cloudinit.readthedocs.io/en/latest/topics/modules.html#users-and-groups
[17:26] <bit48> Okay, thanks
[17:27] <bit48> One last question (I hope) - how does cloud-init merge the user-data from the seed directory with the cloud.cfg file?
[18:02] <rharper> bit48: user-data overrides values found from /etc
[18:03] <bit48> That's what I figured. Thanks.
[21:15] <rharper> robjo: I've updated https://bugs.launchpad.net/cloud-init/+bug/1843634
[21:15] <rharper> if you have more details about the wicked service names and what names cloud-init.service should use to wait for DHCP to be completed; that'd be most helpful
[21:21] <robjo> This doesn't look right, cloud-init-local has "Before=network-pre.target" and the network setup should be complete after cloud-init-local, right?
[21:24] <rharper> not quite;  cloud-init-local runs before networking; in particular it will bring it an interface to read the IMDS for what the config should be; then write out a config to the system, *before* the system networking service starts
[21:24] <rharper> so that cloud-init is feeding network config *to* the OS networking service
[21:25] <rharper> then cloud-init.service wants to run after the OS's networking services have started (and their wait for online service if they have one) so that when cloud-init.service runs, it expects networking is active.
[21:33] <robjo> hmm, sorry cannot dig in right now, need to finish a presentation I am supposed to give next week and am off tomorrow then traveling. I'll find some time to look at this
[21:33] <rharper> robjo: sure, thanks