Repository navigation
fix(roles/cloud_init): reload NetworkManager after removing 99-cloud-init.conf - #466
Merged
Merged
Conversation
…init.conf cloud-init's sysconfig renderer writes "dns = none" to /etc/NetworkManager/conf.d/99-cloud-init.conf. Removing the file had no effect until the next NetworkManager restart or reboot, so /etc/resolv.conf stayed unmanaged in the meantime. The role now reloads NetworkManager via `systemctl try-reload-or-restart`, which leaves a stopped NetworkManager alone (ansible.builtin.service with state reloaded would start it). A reload re-reads conf.d and re-evaluates the DNS mode without touching connections (NetworkManager 1.56, src/core/dns/nm-dns-manager.c, config_changed_cb). The setup_basic scenario recreates the leftover file in prepare.yml and asserts in verify.yml that NetworkManager's DNS mode is no longer "none". Verified on Rocky 8, 9 and 10: the assertion fails with the previous role code and passes with this change; a second run reports changed=0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Rocky 8 and 9, cloud-init's sysconfig renderer writes
dns = noneto/etc/NetworkManager/conf.d/99-cloud-init.confwhenever the provider hands out DNS servers (Hetzner does). Thecloud_initrole removes the file but never reloads NetworkManager, so/etc/resolv.confstays unmanaged until the next NetworkManager restart or reboot. Rocky 10 listsnetwork-managerbeforesysconfigincloud.cfgand does not write the file.Change
roles/cloud_init: removing the file notifies a handler runningsystemctl try-reload-or-restart NetworkManager.service.ansible.builtin.servicewithstate: reloadedwould start a stopped NetworkManager (ansible-core 2.16,systemd_service.py);try-reload-or-restartleaves it alone. NetworkManager has anExecReload, so this never restarts.conf.dand re-evaluates the DNS mode without touching connections (NetworkManager 1.56,src/core/dns/nm-dns-manager.c,config_changed_cb).setup_basicMolecule scenario:prepare.ymlrecreates the leftover file on every host running NetworkManager and asserts the DNS mode isnone;verify.ymlasserts it is no longernone.Testing
setup_basicon all 8 targets, in two batches (idempotence before verify):changed=0) and verify green. NetworkManager does not run there, so the new steps are skipped.changed=0, new assertion green.none).The remaining verify failures on Rocky are unrelated and come from the
linuxfabrik-monitoring-plugins8.0.0 RPM: a corrupt.pycbreaksabout-meon Rocky 9, and AIDE reports rewritten.pycfiles on Rocky 8 and 10 (same as noted in #453).