[13:45] How can I detect network configuration version in cloud init automatically? because I want to write a general script for Linux distros. [13:51] punkgeek: What do you mean by "network configuration version"? Could you perhaps describe your problem/requirement in a little more detail? [13:56] blackboxsw: i'm not really sure why there was a difference. I think powersj might have some insight. Or such knowledge may well be lost in the recesses of past brains. [13:57] but i think that at one point a jenkins had access to one but not the other or something. [14:01] Odd_Bloke: There are 2 kinds of network type which you can see in here: https://cloudinit.readthedocs.io/en/latest/topics/network-config-format-v1.html and https://cloudinit.readthedocs.io/en/latest/topics/network-config-format-v2.html [14:02] Some distoros such as ubuntu 16 use the first version but in ubuntu 18 use the second one (netplan) [14:06] I want to make a script that can detect the OS network type and config it automatically. For example if the Distro support netplan, Use the second network type [14:09] punkgeek: Have you seen the `cloud-init devel net-convert` command? [14:12] Odd_Bloke: This python file? https://github.com/delphix/cloud-init/blob/master/cloudinit/cmd/devel/net_convert.py [14:12] I couldn't understand this python script [14:13] punkgeek: I guess I'm still not sure I understand where this "script" will run, so I'm guessing at what you're trying to do a little. [14:13] punkgeek: "Some distoros such as ubuntu 16 use the first version but in ubuntu 18 use the second one (netplan)" [14:13] the point of cloud-init is that it can render either network config version into the correct system configuration format. [14:14] `cloud-init devel net-convert` will read either version 1 or version 2 network config [14:14] and write sysconfig (rhel, suse), ENI (old ubuntu), netplan (new ubuntu) [14:15] cloud-init *is* the general script [14:16] Aha, So how can I use cloud-init devel net-convert in the iso file? [14:23] I should use it by runcmd command? [14:29] Here is a shell script that I used to config static ip in different distros: https://github.com/autovmnet/tools/blob/master/vm_config.sh But I want to do it by cloud-init iso [14:30] punkgeek: When you say "cloud-init ISO", what do you mean? [14:32] Sorry i'm amature in cloud-init. Here is my cloud-init script example that i've convert it to iso file by using cloud-localds and then mount it on the vm https://github.com/autovmnet/tools/blob/master/cloud-init.cfg [14:35] punkgeek: OK, great; so if you run `cloud-localds`, you should see that it has a `--network-config` option. If you use that to specify network configuration (in either v1 or v2 formats), then cloud-init will take care of rendering it appropriately for your target distro version. [14:36] (And no worries, there's a lot of similarly named things, so I'm just making sure we're on the same page so I'm not giving you bad advice!) [14:47] Thank you, As I understand, in the cloud-localds option, I should create two config file, cloud-init.cfg and network.cfg then convert it to iso file like this: cloud-localds --network-config=network.cfg new.iso cloud-init.cfg [14:47] Am I right? [15:00] punkgeek: Yep, I believe that will do it. [15:02] How can I do it in a single file? [15:04] Odd_Bloke: And is there any way to enter both version configuration and then, system detect version automatically and use the currect one? [15:18] punkgeek: it doesn't matter which you pick [15:18] cloud-init will render either version to the correct result when configuring networking. [15:18] you declare it however you want. [15:23] smoser: Thank you, so is it correct to do sth like this?: create a config.cfg which contain: https://paste.ubuntu.com/p/rXhfRXfWPz/ and then run cloud-localds --network-config=cloud.cfg new.iso [15:23] no [15:25] how should it be? Could you please give me an example to do it? [15:26] Should it seprate the network part and user part? or require anything else? [15:26] https://asciinema.org/a/145772 [15:33] moser: what about this one? moser> [15:33] https://paste.ubuntu.com/p/NTRXsk3Rx6/ [15:35] no. [15:35] thats not valid yaml [15:35] well.. it miht be valid yaml, but its not sensical. [15:35] you have 2 top level network kesy. [15:35] only put one of the two versions in . [15:36] i recommend following the demo and changing one thing at a time. [15:36] all the files for the demo are at https://gist.github.com/smoser/635897f845f7cb56c0a7ac3018a4f476 [15:38] The point what I want to enter both network-config is that because my platform cannot detect the vm distors. [15:40] punkgeek: cloud-init can detect the VM distro (because it runs within the VM), and it will convert your input to the appropriate format for that distro. [15:41] So if it's running on xenial, it will convert v2->ENI, on bionic and later v2->netplan, etc. [15:41] Odd_Bloke: So is it ok to enter both version like this? https://paste.ubuntu.com/p/NTRXsk3Rx6/ [15:42] punkgeek: No. [15:42] You specify your configuration once, and cloud-init converts that configuration to the appropriate format. [15:43] Odd_Bloke: sorry I couldn't understand, could you give me an example? [15:43] (In this case, the second `network` key definition overrides the first, so you are actually only defining a v2 config.) [15:44] punkgeek: https://paste.ubuntu.com/p/VSrFPTzFdz/ <-- that's all you need to specify, cloud-init will take care of converting it to the required format within the VM [15:45] Aha so if i enter this one and the distro does not support netplan such as ubuntu16.04, It will convert to the version one? [15:46] I would like some help troubleshooting my network configuration. I see that my network-scripts were set as expected, but they don't seem to be applied. It seems like it fell back to DHCP for some reason. I'm looking through cloud-init.log now, but I'm not sure what I'm looking for yet. [15:49] I see this in the logs: "No network config applied. Neither a new instance nor datasource network update on 'System boot' event" [15:50] punkgeek: Correct! (In fact it will convert it to ENI, which is the /etc/network/interfaces format used on xenial; v1 is only used internal to cloud-init. But your broader understanding is correct.) [15:56] I got the same when I ran "cloud-init clean -r". I'm new to debugging cloud-init issues, so any help would be appreciated. [15:59] dking: well, you can open a bug. but i'd first explain what you're tryhing to do and paste an entire cloud-init.log . [15:59] Odd_Bloke: Sorry but I've got this error: https://paste.ubuntu.com/p/B8B6MTvrKP/ [16:00] cloud-init collect-logs will collect a lot of information that people would probably ask you [16:00] punkgeek: drop the top level 'network' [16:01] i think newer versions of cloud-init will figure that out, but the bug you're seeing [16:02] the bug you're seeing is that cloud-init looks for a top level 'version' key in its network config, and you have no such key. (because you have a second level network key) [16:02] https://gist.github.com/smoser/635897f845f7cb56c0a7ac3018a4f476 [16:02] those files are valid... if you start there you might have more success. [16:02] smoser: like that? https://paste.ubuntu.com/p/8VTMTqJhXR/ [16:03] Aha sorry [16:04] https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/1798117 intended to support your input [16:04] Ubuntu bug 1798117 in juju "juju sends "network" top level key to user.network-config in lxd containers" [High,Fix released] [16:04] so i'd supsect that the guest that is there does not have that fix. [16:12] smoser: I'm not convinced that it's a bug yet. I'm trying to just get an idea of why things didn't happen as I expected. Here's the cloud-init.log: http://sprunge.us/oqGOws And here is some context: http://paste.openstack.org/show/794705/ [16:14] ...and I forgot to put it in there, but in case it helps, I'm using cloud-init version 18.5 [16:16] what is delphix and how do i run it myself? [16:18] dking: good job collecting info [16:19] you ahve 2 cloud-init runs in the log there [16:19] maybe try a 'cloud-init --logs clean' [16:19] just to reduce it to one boot [16:20] but i suspect that what is wrong is that the /etc/sycconfig is 'diry" in some way [16:20] not certain. but it surely looks good. [16:20] Okay. I'll give that a try. That's probably from where I ran "cloud-init clean -r" [16:20] where did you get the image ? [16:20] Okay, that may be. I had an issue when it first booted caused by the BIOS. [16:20] It's generated by bifrost. This is part of a Kayobe deploy. [16:22] if we think that cloud-init rendered the correct sysyconfig network information [16:22] then there are a few things that might be wrong [16:22] Okay, I ran that (actually "cloud-init clean --logs" as the other way gave an error), and now the logs are empty. [16:23] smoser: Sorry I have this error now; https://paste.ubuntu.com/p/KNhDJHPRQb/ [16:23] a.) cloud-init rendered this network information *after* the system brought up networking (we try to ensure that 'cloud-init init-local' runs before system network bring up . but something might be broken there. [16:23] b.) udev rules might not be written correctly (they handle the device renaming... not exactly sure about that for sysconfig though) [16:24] c.) other confusing sysconfig data conflicting iwth cloud-init [16:25] punkgeek: you gave it invalid yaml [16:25] it can't load it. [16:25] you can test yaml loading using yaml-dump https://gist.github.com/smoser/280dbed3e9582c53c6035525f35814aa [16:26] sorry, though. i really ahve to get to actual work now. [16:26] Yes, they appear to be correct to me, though I could have missed something. Is there any way to tell from the logs where things go wrong? The logs are cleaned now. What is the best way to cleanly run it again? Just reboot the machine, or something like "cloud-init init" ? [16:31] dking, sudo cloud-init --local; sudo cloud-init init; or a reboot as you suggested. https://cloudinit.readthedocs.io/en/latest/topics/faq.html#how-can-i-re-run-datasource-detection-and-cloud-init [16:35] powersj: Thank you very much [16:40] smoser: Here's the new log: http://sprunge.us/q5KrHr and here is further context, including the error I got when attempting to bring up the interface: http://paste.openstack.org/show/794706/ [16:43] dking: init doesnt render networking [16:43] init --local [16:44] OKay. I'll try that. [16:45] smoser: Here's the new cloud-init.log: http://sprunge.us/Scz96q [16:45] do you maybe need some vlan spuport package in the image ? [16:46] i think that maas testing actually uses vlan and centos . so i think this is a supported path [16:49] I use this script but still does not works:( https://paste.ubuntu.com/p/xh25XGpYR7/ [16:52] I'm not sure. I've been using the same system to deploy servers for a while, but I did make some changes to configurations before this run, and it's happened on two different machines. [16:56] falcojr: and Odd_Bloke https://github.com/canonical/cloud-init/pull/431 daily recipe fix for bionic [16:57] If the image isn't built correctly, or if there's some problem outside of cloud-init, I'll just need to know enough to locate the bug in the other software. And I have been using VLANs before. I think, though, that we had to use a certain version of cloud-init as the older ones couldn't support them. I think it was around 18.2? [17:03] falcojr: Odd_Bloke and https://github.com/canonical/cloud-init/pull/433 for xenial [17:05] Is there any way to confirm from the cloud-init.log whether the issue I'm seeing in bringing up eht0.81 manually is actually the reason why the network isn't setup by cloud-init? [17:16] punkgeek: you'd have to post a cluod-init log at this point. [17:17] dking: there should be some system logs for sysconfig somewhere [17:17] but i'm not familiar enough to know [17:19] smoser: I'll continue trying to resolve that. But what I meant was, is there some place in the cloud-init logs where it would show whether it even attempted to bring up that interface, or if it received an error? [17:20] dking: I see in your log that "2020-06-12 16:44:41,585 - DataSourceConfigDrive.py[DEBUG]: network config provided via network_json" [17:20] dking: and you can see cloud-init tries to render this network config in your logs [17:21] 2020-06-12 16:44:41,598 - stages.py[INFO]: Applying network configuration from ds bringup=False: {'version': 1, 'config': [{'type': 'vlan', 'subnets': [{'dns_nameservers': ['8.8.8.8', '8.8.4.4'], 'netmask': '255.255.255.0', 'routes': [{'gateway': '10.8.1.3', 'netmask': '0.0.0.0', 'network': '0.0.0.0'}], 'type': 'static', 'address': '10.8.1.11', 'ipv4': True}], 'name': 'eth0.81', 'vlan_id': '81', 'mac_address': [17:21] 'ac:1f:6b:d0:4d:94', 'vlan_link': 'eth0'}, {'mtu': '1500', 'type': 'physical', 'subnets': [], 'mac_address': 'ac:1f:6b:d0:4d:94', 'name': 'eth0'}, {'address': '8.8.8.8', 'type': 'nameserver'}, {'address': '8.8.4.4', 'type': 'nameserver'}]} [17:21] 2020-06-12 16:44:41,598 - __init__.py[DEBUG]: Selected renderer 'sysconfig' from priority list: None [17:21] saying that it is using the proper sysconfig renderer for the network config it writes. (which aligns with you saying the valid config appears to be in /etc/sysconfig) [17:22] might want to check timestamps of 2020-06-12 16:44:41,598 versus you system logs that say when networking is brought up [17:22] to see if that happening in cloud-init 'after' your network was already up (so the updated config wasn't read by your system) [17:25] you might be able to look through output of `journalctl --utc -o short-precise -u systemd-networkd` on your system maybe ? [17:27] * blackboxsw was just grasping at straws though. [17:31] smose: Here is the log https://paste.ubuntu.com/p/mZM3XbVKcx/ [17:46] blackboxsw: Shouldn't those PRs be for the daily branch, as discussed? [17:48] Odd_Bloke: ohh whoops, force of habit. I was thinking we'd do new-upstream-snapshot to refresh patches and then run fix-daily-branch script to do that. I forgot we can just fix daily only [17:48] right right will fix them [17:48] Nice, thanks! [17:48] hrm. thinking it through though. [17:49] so if we only fix ubuntu/daily/xenial we'll lose that next time we run cloud-init's "cherry-pick" as 'fix-daily-branch' does a git reset --hard origin/ubuntu/$release [17:51] so somehow we might need to keep a log of quilt refreshes applied in ubuntu/daily/$release to 'fix' non-cpick quilt patches. [17:51] I think fix-daily-branch should abort if it finds state other than what it expects. [17:51] so we can re-apply them during the next "fix-daily-branch" [17:52] yeah I think so, I can fold that into a PR I'm working on fix-daily-branch anyway as I ran into an issue with ubuntu/$releases which have no debian/patches/cpick* [17:52] so an abort and we can sort on next cherry-pick [17:52] I would suggest it'll be easier to review if you separate them out instead of folding it in. [17:53] But other than that, sounds good! [17:53] ok will do. [17:53] Also worth noting that the current reset --hard behaviour will just break daily builds again in a way that we already know how to solve, so it's not necessarily the worst situation. [17:58] blackboxsw: Thank you very much for the info. I am starting to wonder now if the problem might be NetworkManager. In the past, I think I've had trouble with it using VLANs. [17:58] dking: cloud-init doesn't attempt to bring up networking information [17:58] it just renders it and lets the OS bring it up [17:58] the goal is that your OS just thinks that was "statically configured" networking that was already there. [17:59] Odd_Bloke: falcojr https://github.com/canonical/uss-tableflip/pull/54 [17:59] handle the no debian/patches/*cpick* case on existing ubuntu/xenial or ubuntu/bionic branches (since we had just performed a new-upstream-snapshot which dropped those cpicks) [17:59] Yep. So, I suppose that if it got the scripts into the right place, then maybe the issue is with something else in the OS. [18:00] punkgeek: you'd need to give /var/log/cloud-init.log . not ust the console log. but i suspect that the issue is that the nic name is not what you expected. ens192 [18:01] smoser: can I use it like ens* ? [18:25] punkgeek: probably not reliably. you may be able to for systems that use netplan natively. [18:25] but really what you need to do is specify the mac addresses [18:29] mac addresses are something you can know from "outside". they're properties of virtual hardware. the names that a given OS chooses to give to that virtual hardware are not reliable [18:30] Odd_Bloke: let's try that again https://github.com/canonical/cloud-init/pull/435 to fix ubuntu/daily/xenial builds [18:31] and actually looks like I'll have to rework another patch :/ n/m Odd_Bloke moving which into the subp module also broke another quilt patch [18:31] as unit tests now fail [18:31] after patches are applied [18:31] * blackboxsw moves it to wip [18:34] blackboxsw: Ack, ping when you want eyes on it again. [18:37] smoser and blackboxsw: Thanks for the help. It helped me to narrow things down. The problem does seem to be from using NetworkManager. If I switch to network-scripts, I can start the VLAN. Now, I just have to find a way to get DIB to build using network-scripts instead of NetworkManager. === mpontillo_ is now known as mpontillo [19:34] Looks like Rick didn't get to my doc PR before the trails called to him, so if anyone wants to do a quick review: https://github.com/canonical/cloud-init/pull/430 [19:37] dking, blackboxsw it probably would be good for cloud-init to document *somewhere* that network manager is not supported at this time. [19:38] and would be better if it noticed somehow that your system was using network manager and said unsupported [19:38] +1 Odd_Bloke [19:38] or alternatively, actually DTRT and rendered network manager. [19:39] smoser: I guess https://cloudinit.readthedocs.io/en/latest/topics/network-config.html#network-configuration-outputs is a bit misleading [19:40] as we specifically call out NetworkManager for netplan backend [19:41] how can I configure cloud-init to use Netplan when ifupdown is also present on the host? [19:41] portdirect: by default in Ubuntu focal and later netplan is preferred over /etc/network/interfaces even if both ifupdown and netplan are present [19:42] is there a doc that lists all the recognized keys and describes them? [19:43] portdirect: on earlier releases of cloud-init you can set the renderer priority order to prefer netplan first [19:44] blackboxsw: im not experiencing this, its prioritizing ifupdown over Netplan for me [19:45] a simple apt-get purge ifupdown gets Netplan working, but this is not viable for my use case :( [19:45] portdirect: by either: 1. providing the following config in /etc/cloud-config.d/90-override-renderer.cfg in your image: https://paste.ubuntu.com/p/ky7V4RvdXT/ [19:47] blackboxsw: trying that now [19:47] portdirect: or 2 providing cloud-config to override this on VM boot (if you aren't creating your own images) https://paste.ubuntu.com/p/f68TbMJRdb/ [19:48] strobelight: do you mean instance data keys? [19:48] or network renderer keys? [19:48] I'm missing the context of your question [19:50] falcojr: sorry about https://github.com/canonical/cloud-init/pull/431 I should have closed it when Odd_Bloke reminded me we wanted to do this against ubuntu/daily/xenial|bionic only (as that is the whole reason we have those branches now; to avoid patch commit/refresh noise in ubuntu/xenial|bionic proper)( [19:52] falcojr: https://github.com/canonical/cloud-init/pull/435 should have more context, but the short of it is that we expect to be dropped into a quilt patch apply failure cli where we need to run quilt push -f, resolve patch apply conflicts manually, quilt refresh to save those updated patches into debian/patches/*.patch [19:54] gotcha === Odd_Bloke changed the topic of #cloud-init to: pull-requests https://git.io/JeVed | Meeting minutes: https://goo.gl/mrHdaj | Next status meeting June 16 16:15 UTC | 20.1 (Feb 18) | 20.2 (Apr 28) | https://bugs.launchpad.net/cloud-init/+filebug [20:02] falcojr: also added some more context for you on this ubuntu-advantage-tools pain https://github.com/canonical/cloud-init/pull/431 [20:03] https://github.com/canonical/cloud-init/pull/431#issuecomment-643460234 actually [20:03] rharper: smoser: Your input on https://bugs.launchpad.net/cloud-init/+bug/1883122 would be really appreciated. :) [20:03] Ubuntu bug 1883122 in cloud-init "`cloud-init status` should distinguish between "permanently disabled" and "disabled for this boot"" [Undecided,New] [20:05] the reason we are in a bit of a pickle on ubuntu-advantage in upstream cloud-init is because the ua-tools project accepted backwards incompatibility of the ua-client CLI and cloud-init also was allowed to design a new set of config directives without worrying about backwards compatibility of the old shell-based ua-tools CLI versus to new ua-tools python-based CLI. As a result we've carried a bit of a patch [20:05] maintenance pain in ubuntu/xenial and ubuntu/bionic branches [20:06] * blackboxsw can't wait to release ubuntu-advantage-tools version 25.0 to xenial and bionic so we can drop the ubuntu-advantage revert stuff [20:06] blackboxsw: that worked perfectly, thank you - though I put the over-ride in /etc/cloud/cloud.cfg.d/90-override-renderer.cfg [20:06] cheers [20:06] cool portdirect good to hear [20:12] NetworkManager is probably fine for most people. I think it's the VLANs. And it may not even be just that. I'm wondering if there could be another solution, like adding a package. [20:18] blackboxsw thanks for the extra context [20:18] Odd_Bloke: looking [20:33] https://github.com/canonical/cloud-init/pull/435 and https://github.com/canonical/cloud-init/pull/436 up for daily build recipe fixes [20:33] with happy instuctions :) [21:40] @blackboxsw user-data and instance meta data. https://cloudinit.readthedocs.io/en/latest/topics/examples.html shows examples, but is that all-inclusive? https://cloudinit.readthedocs.io/en/latest/topics/instancedata.html instance data seems to be vendor-specific, or deployment specific, for example "availability_zone" means nothing when deploying ubuntu on my virtualbox. [22:12] strobelight: yes definitely each platform supports differing values for instance data. so your mileage varies depending on where you are deploying. https://cloudinit.readthedocs.io/en/latest/topics/instancedata.html is the best bet and running `cloud-init query --all` on your platform is the real content you can rely on. [22:13] strobelight: also I put together a couple of sample runs on some platforrms a while back: https://hackmd.io/aAJFerDRRNaoL0Q_vDRYBg it's a bit dated, but there ya go [22:36] @blackboxsw thanks, I'll have a look