/srv/irclogs.ubuntu.com/2020/03/30/#cloud-init.txt

=== tds1 is now known as tds
=== cpaelzer__ is now known as cpaelzer
=== tds3 is now known as tds
Odd_BlokeGaffel: Your paste appears to have expired, it's 404ing.14:04
GaffelOdd_Bloke, I uploaded it again: https://paste.centos.org/view/1077fa4e14:24
GaffelI'm unable to log in through both the TTY and SSH. The passwords have no effect. The file is literally "user-data" but nothing I type in that works. It only likes "meta-data".14:27
Odd_BlokeGaffel: I don't have time to dig into this too much right now, but line 17 appears to be indented by an additional line.14:28
Odd_BlokeThat might be causing the password setting to fail?14:28
GaffelThat's weird. I don't see that on my system. I pasted it manually. I'll check if there's no indentation issues in the file.14:29
GaffelThere are no tabs. That must haven't happend when I pasted.14:30
GaffelI cut away the "users" stuff and only kept the chpasswd and ssh_authorized_keys. Now it lets me log in. :|14:41
GaffelIt uses cloud-init 18.514:42
GaffelHow can I test user-data since it won't let me access anything until now when the things I want to test has been removed?14:44
powersjGaffel, we have a couple of ways documented via LXD and Mulitpass in addition to validating your YAML: https://cloudinit.readthedocs.io/en/latest/topics/faq.html#how-can-i-debug-my-user-data14:45
powersjI would at least try the devel schema command14:45
powersjnot everything has schema, but it is worth a try14:46
anankeGaffel: you also may want to start with something simpler: don't add additional users, just set password & keys for the default one14:47
anankeGaffel: is this in ec2?14:48
GaffelIt's just local, I just want to test cloud-init, so you can use images without modifying them14:49
GaffelIt looks like it doesn't like my "sudo" string.14:49
Gaffelpowersj, thanks for the tip. I thought that this was valid YAML but it seems to have issues. :/14:49
anankemultipass has a few issues though with cloud-init14:51
anankealthough your configs are simple enough they shouldn't be impacted by that. namely jinja2 templates14:52
GaffelIt works now. Thanks for the help! :] (now I just need to fix the things I actually wanted to try from the beginning)14:59
Odd_BlokeI'm still waiting for review on one of my cleanup PRs from last week: https://github.com/canonical/cloud-init/pull/28315:30
anankeuhmm, is cloud-init.service supposed to be enabled or is it handled via other means? Wonder if my kali linux issue is related to the following:15:30
anankeroot@kali:/etc/cloud# systemctl status cloud-config.service15:30
ananke● cloud-config.service - Apply the settings specified in cloud-config15:30
ananke     Loaded: loaded (/lib/systemd/system/cloud-config.service; disabled; vendor preset: disabled)15:30
=== tds2 is now known as tds
Odd_Blokeananke: All the units should be enabled together, either explicitly on installation or by cloud-init.generator (if it's been installed).15:32
Odd_Blokerharper: We forgot to assign PRs in our daily meeting, but there's only one pending assignment, so I've just put your face on https://github.com/canonical/cloud-init/pull/28915:33
anankemakes me think that Kali people mangled cloud-init installation15:35
Odd_BlokeIt's certainly a possibility.15:37
rharperOdd_Bloke: ok15:48
Odd_Blokeblackboxsw: When you merged #288, the merge commit message ended up truncated at the first comma.  Don't know how that happened, just a heads-up to keep an eye out for it.16:25
blackboxswOdd_Bloke: thanks, yeah that's strange. and probably my end. Odd_Bloke rharper when we are squash merging are folks redacting the per-commit messages that github appends to the original PR description?16:26
blackboxswfor instance, if I have 10 commits in my squashed PR, github adds one line preceded by an asterisk  for each additional commit16:26
blackboxswin cloud-init's launchpad world, our squash merge would only use the branch description or top-most commit message as the squashed commit16:27
Odd_BlokeI have been removing any that don't add useful information.16:27
Odd_BlokeLike "* typo fix" doesn't help anyone.16:27
blackboxsw+1 Odd_Bloke, I generally have been doing the same.16:28
blackboxswI think I just botched 28816:28
Odd_BlokeBut "* Fix the behaviour of Spam.eggs() when "ham" is passed" is useful for someone ending up at the squash commit via blame.16:28
anankehmm, so it appears that Kali AMI has both cloud-config.service and cloud-final.service disabled by default. that doesn't make sense16:33
blackboxswso, rharper I guess we have https://github.com/canonical/cloud-init/pull/267 then for Focal.    and Odd_Bloke or rharper more jsonschema coverage to help folks w/ malformed user-data  https://github.com/canonical/cloud-init/pull/15217:05
rharperananke: saw you update, will look at the data later.    w.r.t the services,  they should be 'vendor preset: enabled'17:06
anankerharper: makes me wonder if kali linux folks have done some rudimentary setup required by amazon, and disabled what they didn't think was necessary. I've opened a bug with them as well: https://bugs.kali.org/view.php?id=623917:10
anankenow I need to figure out if I can fix this on first boot for cloud-init status --wait to function, or would it require another reboot17:11
rharperananke: something that might work is a bootcmd which ran 'systemctl enable cloud-config.service; systemctl enable cloud-final.service'17:50
anankerharper: funny enough, that's exactly what I'm trying to test now. I was also going to put in 'systemctl start' for both of them, or is that not necessary at that stage?17:53
anankeproblem is that the first time cloud-config.service starts it fails, but then starting it the second time works17:54
anankethis is the error, I think I'll have to fix it before I can try the other stuff: http://dpaste.com/37R31X617:56
Odd_Blokeananke: That looks like a misconfigured /etc/cloud/cloud.cfg{,.d/*}.17:58
anankeit appears to break on 'security' key, and the only place that word appears is in /etc/cloud/templates/sources.list.ubuntu.tmpl17:59
anankeand templates/sources.list.debian.tmpl17:59
Odd_Blokeananke: My guess is that you're missing something like https://github.com/canonical/cloud-init/blob/master/config/cloud.cfg.tmpl#L172-L19618:00
Odd_BlokeOr, alternatively, "apt-configure" shouldn't be configured to run, if Kali isn't a Debian derivative.18:00
anankeit's debian alternative, but I wonder if they don't have 'security' repo. Here's their /etc/cloud/cloud.cfg: http://dpaste.com/2DM65Q318:01
Odd_BlokeYeah, I was about to say that yet another alternative is that cc_apt_configure needs to learn that security mirrors are not universal.18:02
Odd_BlokeBut if you want something that doesn't require cloud-init code changes, then replicating that final line with s/primary/security/ might do it.18:03
anankefor rolling release distros that may be the case18:03
anankeOdd_Bloke: thank you, that's a great idea18:03
Odd_Bloke(It should definitely get you past the KeyError, I'm not sure if apt will warn you about duplicate sources, though.)18:05
anankeI'll test it on this instance, after I remove the proper semaphore. in theory this section of cloud.cfg could be overwritten by a file in /etc/cloud.cfg.d/myfile.cfg, right?18:06
Odd_BlokeYes, though you have to replace the entire value of top-level keys.  So you'd need to replicate the entire `system_info:` dict in there, and then make your changes to that.18:07
Odd_Blokes/dict/mapping/, let's not confuse YAML and Python terms.18:07
anankek. I was wondering about that. I'm already dropping in a file with partial system_info: set of keys, including default_user. Do I have to copy the _entire_ default system_info: section?18:11
rharperananke: depends on what you're changing;  dict merging rules will apply, so the last config will clobber previous values;18:13
rharperananke: I don't think you want to start them;  they just need to be enabled ... and I updated the bug, the other issue is that /etc/cloud/cloud-init.target.wants did not have all 4 services added18:14
anankerharper: I'm changing the default username and gecos field. looks like I could do: http://dpaste.com/094W28X18:14
rharperso combine all services enabled, and an updated .wants and systemd should run all 4 services ... and need to sort out if you're making it to network-online.target18:14
rharperyou can modify the default users with 'users': top-level key instead of system config18:15
rharperhttps://cloudinit.readthedocs.io/en/latest/topics/examples.html18:15
anankeohh, interesting. thank you. not sure how we arrived at system config for the default users, perhaps some old examples18:15
anankerharper: I was under the impression that 'users' provided ability to add additional users, but to change the username/gecos of the default we had to override it with system config18:17
rharpersure18:17
rharperunless you want to keep the distro default user and modify it; in your case you're changing the name anyhow, so users: [{'name': 'student', 'gcos': 'Cyber Range Student'}]  will do what you want, making 'student' the default user,18:19
rharperIIUC18:19
rharperif you wanted both, you have users: ['default', {'name': 'student'}] ...18:19
rharperbut I'm guessing you want the former18:20
anankein my tests with ubuntu 18.04 it seemed to add a new user, rather than override the default one18:20
rharperhrm,18:21
anankeand regarding earlier comment about cloud-init.target.wants, looks like I had to also enable cloud-init-local.service.18:23
anankeso lesson learned, simply enabling cloud-config.service and cloud-final.service via bootcmd didn't seem to be sufficient, I had to ssh in and start them. wonder if reloading systemd would help18:43
anankeit may be too late in the boot process18:43
rharperananke: so, since they weren't enabled or included in the cloud-init.target.wants, when cloud-init systemd generator runs it does not pull in all of the cloud-init units;  if you are making changes in early boot, you will also need to:  1) systemctl daemon-reload 2) likely need to run systemctl start --no-block  <service name> ;;; but I'm not sure if that will attempt to run the job righ t away or if it will wait for the right time to start ...18:57
rharperananke: you really need modifications to the base image; I suspect your bug against kali itself would be where they'd fix the install of cloud-init correctly18:58
anankerharper: thanks for the explanation. Yes, the problem needs to be addressed in the base image. I'm suspecting whoever is making that AMI wasn't too familiar with cloud init. I'll pass everything I find to the bug I have open with Kali19:01
anankewith that in mind, our goal is to take a base image, adjust it as needed for our purposes via automated means (packer + cloud init + scripts) and create a new image. So I'm creating a temporary band-aid solution here19:02
rharperananke: great.19:04
rharperdoes packer let you run scripts on the image before booting it ?19:04
anankerharper: yes and no. since the source is an existing AMI, the only thing we can pass is user-data with cloud-init specific items19:06
anankeso it's like a chicken & egg problem. I have to fix cloud-init via cloud-init :)19:06
Odd_Blokerharper: blackboxsw: https://github.com/canonical/cloud-init/pull/291 <-- the mirror URL substitution PR19:09
rharperananke: I wonder if you used the virtualbox image, convert it to raw or qcow2 format;   then you can loopmount it and make changes19:09
anankethe basic steps are: 1) packer creates a new ec2 instance from a source AMI, and passes it user-data, 2) the very first 'provisioner' we have configured with packer is 'cloud-init status --wait'. packer connects via ssh as soon as sshd is available and runs that. 3) we run various other scripts, including cloud-init configs/scripts19:09
rharperananke: and then upload that as an AMI19:09
Odd_Bloke(Another small one will follow, to address the TODO called out inline.)19:09
anankerharper: it was a thought, but we're trying hard to avoid that. it requires tons of additional work19:10
rharperananke: ok, one other thought;  once you're in; instead of just running cloud-init status --wait;  you can drop the wait; and if you know what stage of cloud-init you are running (or looking to see if it's actively running) wait for the stage to complete and then manually run the following stages;  cloud-init modules --mode=config;  cloud-init modules --mode=final19:11
rharperyou may be able to avoid "fixing" the original kali image to boot correctly and then you only need to apply proper fixes to the current image in your script (rather than bootcmds)19:12
rharperOdd_Bloke: ok19:12
anankethanks! I'll try that19:13
Odd_Blokerharper: Thanks for the initial comments, I've replied to them all.19:51
anankesuccess! https://gitlab.com/kalilinux/packages/base-files/-/compare/d5519cfc422157245bfec9d6d35271b1b810480b...09e4f2bbd27044a6cb274847400e646b1703ad5e20:48
anankeI also suggested added the workaround for security repository, so hopefully that will be added soon20:49
rharperananke: nice!20:53
anankeall credit goes to you for finding various things. I should comment on the bug I have open with cloud-init and link my bug open with Kali20:53
anankeI haven't looked in the cloud-init code much, but for the security repository issue in kali would creating a new /etc/cloud/templates/sources.list.kali.tmpl without that key work, along with setting distro type to 'kali' under system_config key?21:01
Odd_Blokerharper: I've updated the commit message; where would you suggest we document the change in behaviour other than that?21:04
Odd_Bloke(We don't really have release notes per se, right?)21:04
rharperOdd_Bloke: I was thinking in docs around apt templating ... maybe we don't have a section on that21:24
rharpermaybe we don't21:25
rick_h_pvt21:50
rick_h_bah21:50
Odd_Blokeblackboxsw: rharper: A small design section on type annotations: https://github.com/canonical/cloud-init/pull/293 and a couple of small cleanup PRs: https://github.com/canonical/cloud-init/pull/292 https://github.com/canonical/cloud-init/pull/29422:08

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