/srv/irclogs.ubuntu.com/2024/09/04/#cloud-init.txt

holmanbminimal: question doesn't apply to alpine :P05:34
holmanbminimal: but basically I'm proposing that cloud-init shouldn't set a locale by default05:37
holmanbminimal: here's the bug I filed if you're curious https://github.com/canonical/cloud-init/issues/564905:38
-ubottu:#cloud-init- Issue 5649 in canonical/cloud-init "[enhancement]: stop setting a default locale" [Open]05:38
holmanbmy claim is that there is not a sufficiently good enough reason for cloud-init to set a default locale, so cloud-init should only set locale in response to user-data received05:42
=== arif-ali_ is now known as arif-ali
=== SirScott3 is now known as SirScott
txtsdHow do I prevent cloud-init from injecting DigitalOcean's DNS servers on my VPS?08:34
txtsdsystemd-resolved has 1.1.1.1 by default and also has DNSSEC on. DigitalOcean's DNS servers don't support DNSSEC and so DNS resolution is either mad slow or straight-up fails.08:35
txtsdI found `resolver-fix` in `/var/lib/cloud/instances/<snip>/boothooks/` that's doing this. I suppose this file is created during bootup etc, so how do I stop it from running?08:38
falcojrtxtsd: I don't know how that particular boothook is provided...whether it is baked into their image vs being provided as vendor data. If it is a part of vendor data, you could pass user data with "vendor_data: {enabled: false}" as part of your cloud-config (see example 3 at12:42
falcojrhttps://cloudinit.readthedocs.io/en/latest/reference/modules.html#scripts-vendor)12:42
falcojrthough I do think that DO provides additional vendor data that you'd be disabling12:42
falcojrif it's baked into the image, there's no good way that I can think of via cloud-init...you'd probably need to create a custom image where you remove that particular script12:43
Odd_BlokeI believe it is provided via vendor-data (though, yeah, there is a fair amount of other vendor data you'd also be disabling).13:14
minimalwhichever DataSource is being used by the VM image may also be relevant - the Dataocean DS is deprecated and so I'd assume ConfigDrive is being used instead13:17
minimals/Dataocean/Digitalocean/13:17
Odd_BlokeWill /var/lib/cloud/instance have been set correctly by the time boothooks run?  I'm looking at https://cloudinit.readthedocs.io/en/latest/explanation/format.html#example-of-once-per-instance-script and wondering if I can use a `/var/lib/cloud/instance/sem` file to simplify the changes.13:45
falcojryes, the instance link should be correct by then, but I'm not sure I'm following about a sem file13:47
Odd_BlokeIf I insert `[ -f /var/lib/cloud/instance/sem/do-dns ] && exit 0; touch /var/lib/cloud/instance/sem/do-dns` at the top of the boothook, I think it should only run the rest of the script once per instance?13:49
falcojrI see what you mean. Yeah, that should work for first boot and then it could be updated manually by others or in a later stage for subsequent boots. I wouldn't recommend vendors writing any data directly into /var/lib/cloud and would consider that unsupported in case we modify anything there, but the concept makes sense13:58
falcojrI realize the example does that...but I should also update the example :D13:59
Odd_BlokeHaha, yeah, I was about to observe the same.  I know of `cloud-init-per` to execute a separate script per-instance; is there anything analogous which I could call from within a script?  (Which I could use something like `cloud-init-per --check instance do-dns || exit 0` in this context.)14:03
Odd_BlokeHmm, something like `cloud-init-per instance do-dns false` might be a rough facsimile of that.  If it exits 1, then we haven't run before.14:11
blackboxswfunny as well I was just writing up an example for that. But if the do-dns operation is complex you'd have that script writing it's separate script every boot anyway just to ensure the script is there.   How about a header command in the script  `cloud-init-per instance do-dns exit 114:11
Odd_BlokeHah, great minds etc.14:13
blackboxswsorry thinko on the exit 1 don't want early exit, but yes some clause that'd low us to introspect "return value" and proceed on first run, exit on subsequent run14:14
Odd_BlokeHuh, `cloud-init-per instance do-dns false` exits 1 the first time and 0 subsequent times; `... exit 1` exits 1 every time and doesn't seem to write the sem file.14:16
falcojryou could technically throw the entire script under `cloud-init-per`. E.g., `cloud-init-per instance do-dns bash -c ' ... ' `14:16
Odd_Bloke(`cloud-init-per instance do-dns bash -c 'exit 1'` does behave as I would expect.)14:17
blackboxswOdd_Bloke: your `cloud-init-per instance do-dns /bin/false || exit 0` would do it too I think14:18
blackboxswsorry typo `cloud-init-per instance do-dns /bin/false && exit 014:20
blackboxswso every run after first boot would exit 0 14:21
blackboxswuntil instance-id changes14:21
Odd_BlokeYeah, I think I'll try that.  The way we're generating this makes the `bash -c` approach complicated, else I think I would lean towards that.14:28
=== kuraudo1 is now known as kuraudo
txtsdY'all I went down the rabbithole to fix it: https://ihavea.quest/posts/2024-09-04-digital-ocean-arch-dns/15:24
minimaltxtsd: the systemd network files are created by cloud-init based on the network-config provided by DigitalOcean to cloud-init15:40
minimalwhich is either provided by the DigitalOcean metadata server (if cloud-init used the DigitalOcean datasource) or a file in the ISO (if cloud-init used the ConfigDrive datasource)15:41
minimalbasically the principle in a cloud environment is that the Cloud Provider specifies network-related settings (which would include DNS)15:42
=== kuraudo1 is now known as kuraudo
holmanbtxtsd: glad you figured it out18:25
holmanbThis highlights one of the major downsides of vendors providing vendor-data as scripts - it makes it difficult for users to override specific behaviors.18:30
holmanbif vendors used cloud-config instead that would allow users to override vendor-data with more nuance than "turn it off"18:35
Odd_BlokeThe problem in cases like this is (IIRC!) that a vendor-data provided cloud-config `bootcmd:` would be overriden by any bootcmd provided by the user, who may not even be aware that a bootcmd is being run until their instance doesn't work as expected.18:44
Odd_Bloke(And if there are multiple bootcmds, they still I think only have the "all or none" option even specifying merging configuration.)18:45
holmanbOdd_Bloke: the problem still applies to shoving arbitrary code into bootcmd, agreed19:09
holmanbOdd_Bloke: but there is a cloud-config module for setting resolvconf19:16
Odd_BlokeI don't believe it's enabled by default, though (as `manage_resolv_conf` defaults to False, I think): so we'd have to opt users into cloud-init-generated resolvconf (and have those values written into a single global file) vs. leaving distro config intact and writing a .d file with just the DNS servers.19:26
minimalholmanb: there is cc_resolv_conf for setting /etc/resolv.conf, which is NOT resolvconf/openresolve19:28
holmanb@Odd_Bloke:  It would be trivial to set `manage_resolv_conf: true` as part of the vendor configuration (indeed - that's how a user would override this setting)19:29
holmanbbut you're right that overriding the distro config is not ideal19:29
minimals/openresolve/openresolv/19:29
Odd_BlokeRight, but then we change the behaviour of _all_ instances just to support the very limited subset of our users who don't want to use our DNS servers (plus there isn't a clue in the .d filename as to where these magic IP addresses have come from).19:30
holmanbbut it would probably actually be a better cloud-init default to not override the vendor's `/etc/systemd/resolved.conf`19:30
minimalaren't you getting 2 distinct things mixed up? cc_resolv_conf is only for creating a single /etc/resolv.conf file whereas resolvconf/openresolv is an alternative mechanism where *multiple* config files can be used19:31
holmanbso a `/etc/systemd/resolved.conf.d/cloud-init.conf` would give the breadcrumb to users about where the config came from - and the template could include a note about where it came from19:32
holmanbminimal: cc_resolv_conf actually supports systemd too19:32
holmanbit's just not well documented19:32
minimalhmm, just seeing that too, ok, I'm not familiar with that, only with "classic" /etc/resolv.conf19:32
minimalI've been meaning to add openresolv support for Alpine to cloud-init19:33
holmanbyeah it just uses a different template and file path19:33
Odd_BlokeOh, I think cc_resolv_conf doesn't even run on Debian/Ubuntu, actually.19:34
minimalOdd_Bloke: yupe, they're not listed in the "distros"19:35
holmanboh, yeah that's true19:35
holmanbbut no reason that it couldn't19:35
minimalbecause I assume they use resolvconf instead19:35
holmanbas for change in behavior - stable distros patch out breaking changes as needed19:35
holmanbminimal: ubuntu uses systemd-resolved 19:36
Odd_BlokeYeah, resolvconf has been in universe since bionic.19:36
minimalholmanb: so looking at cc_resolv_conf, for systemd OS' it only writes to /etc/systemd/resolved.conf rather than dtopping a file into /etc/systemd/resolved.conf.d/ and so it overrides the default/global config19:37
holmanbminimal: yeah, earlier I mentioned that19:38
holmanb> but it would probably actually be a better cloud-init default to not override the vendor's `/etc/systemd/resolved.conf`19:38
minimalwell any file in /etc/systemd/resolved.conf.d/ would override the global file19:39
holmanbI think we're talking about different things - overriding settings vs overriding the file19:40
minimalyeah, I meant override settings ;-)19:41
holmanbwe don't want cloud-init to overwrite the file19:41
holmanbbased on the upstream default config only alpine and photon use this module19:55
minimalfrom memory on Alpine if DNS servers are specified in network-config v1/v2 then those end up in the c-i generated eni file but they're not actually used by Alpine20:00
minimalwhereas those specified in user_data for "resolv_conf:" end up in /etc/resolv.conf20:01
holmanbinteresting20:01
minimalso effectively there are 2 conflicting places for nameservers to be specified to give to cloud-init20:01
holmanbyeah, it's not ideal20:02
minimalI *think* if I get openresolv going on Alpine with cloud-init then there'd be no need to use cc_resolv_conf20:03
minimaldo note the docs for cc_resolv_conf say "Many distros have moved away from manually editing resolv.conf so please verify that this is the preferred nameserver management method for your distro before using this module."20:04
holmanbhowever, network config can't be modified by users at runtime (though maybe it should?)20:04
holmanbyeah I'm pretty sure the git blame points back at me for that sentance20:04
minimaloops, after that it says "Note that using Network configuration is preferred, rather than using this module, when possible."20:05
minimalso that explains why you only found Alpine and Photon having the module in cloud.cfg20:05
holmanbbecause we were getting questions about how to use it and at the time I wasn't awaare that it supported systemd 20:06
holmanb(but also it's still better to steer people away from a module that isn't universally available)20:06
holmanbminimal: maybe adding resolv.conf support to ENI would be easier if that's the default resolver on alpine?20:07
minimalre: network config "though maybe it should?" - I always think (in a cloud) of meta-data and network-config as being controlled by the Provider (it's *their* network after all) though the presented network config can be "influenced" by your actions (i.e. you create a VPC and put a VM in it, AWS then presents network info relating to that VPC)20:07
minimalholmanb: now that 24.3 is out I'm starting to look at my notes for what to work on next. Ideally I'd want to support openresolv as well as /etc/resolv.conf. I'll have to re-familiarise myself with the eni.py code to see what's involved in get either/both resolv.conf and openresolv populated from ENI20:11
holmanbre: can be "influenced" by your actions20:12
holmanbsure, but do vendors always expose the knobs users want?20:13
minimalwhich goes back to "it is their network after all" ;-)20:13
holmanbbut as the user it's _my_ instance20:13
minimalyupe but running on _their_ network20:14
holmanban when presented with no better alternatives, users may look elsewhere - at competitors, or going on-prem20:15
minimalso actions such as adding a 2nd interface to a VM plumbed into another VPC with DHCP enabled etc then automagically revise the network-config presented by the IMDS20:15
minimalDNS settings are an "outlier", the vast majority of network-related settings in a Cloud infra reflect config defined in the Cloud (VPC, interface, subnets, IPv4/v6 enabled, etc)]20:18
holmanbyeah, that's a nice mental model but in this case the vendor isn't even using network-config to spray their DNS settings20:22
holmanbOdd_Bloke: is there some reason why network-config isn't used for DNS instead of a vendor script?20:26
minimalamd it's not even clear *which~* DS is being used20:26
minimalthere's also DHCP option for DNS Nameservers to throw into the mix too.... ;-)20:30
minimala cloud/hypervisor could use that to specify nameserver(s) to use20:31
minimalholmanb: BTW re: Alpine, the issue wasn't with c-i's eni.py (it writes the nameserver entries fine), it is that Alpine's ifupdown-ng code doesn't look for/use those ENI entries, that's an issue/bug I need to look into20:33
minimalthe same applied for the ifupdown package Alpine used to have which was a fork of the Debian code (but the Debian code had a /etc/if-up.d/resolved hook to talk to systemd-resolved)20:34
Odd_Blokeholmanb: I'm unsure: I don't actually own our vendor-data, I just saw the issue in here and picked it up.20:44
Odd_BlokeIt does look like the servers are _also_ in network-config.20:46
holmanbhuh20:54
holmanbthat's odd20:54
holmanbminimal: gotcha20:54
holmanbminimal: were you still looking at lvm for cloud-init / growpart?21:38
minimalholmanb: yes it (as well as LUKS) are on my list - I was working on growpart & LUKS several months ago before I got diverted by the big lock_passwd stuff21:49
minimalI wanted to get the growpart & LUKS sorted first before moving onto LVM21:50
holmanbgotcha22:37
minimaloholmanb: BTW AWS does let you control DHCP options for VPC and so yes a VM could get DNS servers from DHCP as well as from network-config and/or user-data resolv_conf22:49

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