[07:08] holmanb: yes, but where would it fit into this picture: https://github.com/canonical/cloud-init/blob/main/WIP-ONGOING-REFACTORIZATION.rst [12:47] holmanb: there's also an… well, two ifconfig parsers in netinfo.py [14:33] meena: the wip doc predates my involvement, I'm probably not the best person to answer that since I was not involved in those discussions [14:34] phunyguy: thanks for the ping, I'll get back to you on the PR today, haven't taken a look yet sorry [18:14] holmanb: yeah, one of the main people involved is no longer in Canonical… but blackboxsw and rharper (and probably smoser as one of the authors of netinfo.py) should have some clue where best to put it… and what to do with netinfo.py… [19:02] so here's a fun frustrating discovery this morning: ubuntu uses /bin/dash as 'sh', which does NOT have 'source' [19:02] so some of my runcmd was failing because of that [19:18] ananke: don't most linux distros run dash these days? [19:19] holmanb: not that I'm aware of, only debian/ubuntu based ones [19:19] holmanb: apart from Alpine which uses Busybox sh which is basically "ash" [19:19] rhel/fedora/suse/sles/etc don't use dash [19:21] ananke: isn't "source" not a POSIX thing and the POSIX way is "."? [19:21] on distros that link /bin/sh to bash, and execute bash in bourne shell compatibility mode that way, 'source' works. not a big deal, I will switch to `.`, but it was a frustrating to debug [19:21] minimal: correct [19:22] ananke: so /bin/sh is supposed to be POSIX-compatible - if you want to use "source" then put "/bin/bash" at the top of your scripts [19:22] ananke: my bad, there was some discussion post-shellshock about switching to dash, I guess that never happened [19:23] minimal: that's the thing, I'm not putting anything at the top of my scripts, this is runcmd module doing it [19:23] ananke: also try using "shellcheck" to validate your scripts for correctness? [19:24] ananke: hmm, ok, I don't think I've ever uses "runcmd" on a script without a shebang line specified [19:24] minimal: runcmd accepts individual commands as input, and creates its own script [19:27] ananke: how about this then? [19:27] runcmd: [19:27] - [ "bash", "-c", "source whatever; "] [19:27] ananke: yeah, was getting mixed up with write_files for script creation [19:28] when passed as a list of args, it should be like execve, rather than `sh` [19:28] holmanb: it's not a problem anymore, because I identified the root cause. so using '.' works [19:29] I was simply sharing something that may be of interest to others. a simple '- source something' in runcmd works on rhel/centos/amazon linux/suse/etc, but not on debian/ubuntu [19:30] ananke: Sounds good, glad you got it sorted. TIL thanks for sharing :-) [19:30] for any Unix-like system the only assumption is that /bin/sh exists and it is POSIX-compatible, it would be complicated for cloud-init to try to be smarter [19:32] minimal: right, it's my fault for not writing it correctly in the first place. I partly blame bash for not working as expected when running in sh compatibility mode, because I would have caught it much earlier [19:37] Bash's POSIX mode apparently does support "source" in some fashion according to points 30 & 42 here: https://www.gnu.org/software/bash/manual/html_mode/Bash-POSIX-Mode.html [19:48] interesting side note. runcmd docs on https://cloudinit.readthedocs.io/en/latest/topics/modules.html#runcmd mention: 'when writing files, do not use /tmp dir as it races with systemd-tmpfiles-clean LP: #1707222. Use /run/somedir instead.' [19:48] Launchpad bug 1707222 in cloud-init (Ubuntu) "usage of /tmp during boot is not safe due to systemd-tmpfiles-clean" [High, Fix Released] https://launchpad.net/bugs/1707222 [19:49] it's worth pointing out that some distros mount /run with noexec [19:50] for what it's worth: FreeBSD sh doesn't know about source either [20:02] alias source=. [20:02] works… [20:16] meena: so does '.' :) [20:47] ananke: please dont rely on the fact that runcmd puts all commands into a single shell file that maintains state across entries in runcmd. [20:48] that was a bad implementation choice. [20:48] those who made such a choice shall remain anonymous. [20:51] smoser: thank you for that hint, I may have to rethink some of our approach [20:52] ananke: you can do all sorts of things with yaml to make it palatable [20:52] vast majority of code we execute via cloud-init is stored in files, written by cloud-init, so it's not an issue. the reason why I'm doing some stuff via runcmd is it's ad-hoc nature, and more importantly: it runs as the very last step [20:59] ananke: https://pastebin.com/raw/y0nGTsWV . i feel dirty for using pastebin.com, but that is something i woudl do in user-data. it makes heavy use of yaml anchors to make things more readable. [21:11] smoser: cheers, that will be very helpful [21:12] it's quitting time though, so this will have to wait until the morning. along with trying to figure out why my runcmd stuff is executed twice.