From 578a257c3858484cd26415f1490f3b4ce1b15ccb Mon Sep 17 00:00:00 2001 From: Matt Crees Date: Mon, 4 Dec 2023 09:54:52 +0000 Subject: [PATCH] Stop NetworkManager from overriding resolv.conf When ``resolv_is_managed`` is set, Kayobe templates resolv.conf. This patch stops NetworkManager from overriding these changes. Closes-Bug: #2044537 Change-Id: I90b61dfe03d53c58327d2b15e70b7b8489bdfb47 --- ansible/roles/network-redhat/tasks/main.yml | 16 ++++++++++++++++ ...-resolv-conf-management-141788e64d0e82a0.yaml | 6 ++++++ 2 files changed, 22 insertions(+) create mode 100644 releasenotes/notes/fix-resolv-conf-management-141788e64d0e82a0.yaml diff --git a/ansible/roles/network-redhat/tasks/main.yml b/ansible/roles/network-redhat/tasks/main.yml index 754ea2333..7df70b0f7 100644 --- a/ansible/roles/network-redhat/tasks/main.yml +++ b/ansible/roles/network-redhat/tasks/main.yml @@ -4,6 +4,22 @@ when: resolv_is_managed | bool become: True +- name: Ensure NetworkManager DNS config is present only if required + become: true + community.general.ini_file: + path: /etc/NetworkManager/NetworkManager.conf + section: main + option: "{{ item.option }}" + value: "{{ item.value }}" + state: "{{ 'present' if resolv_is_managed | bool else 'absent'}}" + loop: + - option: dns + value: none + - option: rc-manager + value: unmanaged + when: + - ansible_facts.os_family == "RedHat" and ansible_facts.distribution_major_version == "9" + - name: Configure network interfaces (RedHat) import_role: name: MichaelRigart.interfaces diff --git a/releasenotes/notes/fix-resolv-conf-management-141788e64d0e82a0.yaml b/releasenotes/notes/fix-resolv-conf-management-141788e64d0e82a0.yaml new file mode 100644 index 000000000..102af06b2 --- /dev/null +++ b/releasenotes/notes/fix-resolv-conf-management-141788e64d0e82a0.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixes a bug where NetworkManager would overwrite resolv.conf when + ``resolv_is_managed`` is set to ``True``. + `LP#2044537 `__