Skip to content

Commit 3d97eb0

Browse files
committed
Reload crc NetworkManager in reproducer
The fix for reproducer dns[1] does not seem to work in all instances. NetworkManager was still overwriting the /etc/resolv.conf contents, so this change reloads the service after changing the config to ensure it does not modify the resolv.conf on reboot. Additionally, instead of rebooting, restart the dnsmasq service. [1] #1637
1 parent d004459 commit 3d97eb0

File tree

1 file changed

+43
-2
lines changed

1 file changed

+43
-2
lines changed

roles/reproducer/tasks/configure_crc.yml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
# Managed by ansible/cifmw
4444
nameserver {{ _crc.ip_v4 }}
4545
46+
- name: Reload NetworkManager to ensure it read the conf changes
47+
become: true
48+
ansible.builtin.service:
49+
name: NetworkManager
50+
state: "reloaded"
51+
4652
- name: Check which dnsmasq config we must edit
4753
register: _dnsmasq
4854
ansible.builtin.stat:
@@ -84,9 +90,44 @@
8490
regexp: "listen-address={{ _crc.ip_v4 }}"
8591
replace: "listen-address={{ _crc.ip_v4 }},127.0.0.1"
8692

87-
- name: Reboot CRC node
93+
- name: Restart dnsmasq service when available
94+
when: not _dnsmasq.stat.exists
8895
become: true
89-
ansible.builtin.reboot:
96+
ansible.builtin.service:
97+
name: dnsmasq
98+
state: "restarted"
99+
100+
- name: Restart dnsmasq container for older crc versions
101+
when: _dnsmasq.stat.exists
102+
become: true
103+
block:
104+
# taken from
105+
# https://github.com/openstack-k8s-operators/ci-framework/blob/73e5170693c18f5d244c91f83ad240f6804cbec9/ci/playbooks/multinode-customizations.yml#L111
106+
# Avoid 'state: restarted' due to issues with IP not
107+
# available when crc-dnsmasq starts
108+
- name: Stop dnsmasq
109+
become: true
110+
ansible.builtin.systemd:
111+
state: stopped
112+
name: crc-dnsmasq
113+
114+
- name: Make sure that crc-dnsmasq is not running
115+
containers.podman.podman_container:
116+
name: crc-dnsmasq
117+
state: absent
118+
119+
- name: Start dnsmasq
120+
become: true
121+
ansible.builtin.systemd:
122+
state: started
123+
name: crc-dnsmasq
124+
register: _dnsmasq_start_reg
125+
retries: 15
126+
delay: 20
127+
until:
128+
- _dnsmasq_start_reg.failed is false
129+
- _dnsmasq_start_reg.status is defined
130+
- _dnsmasq_start_reg.status.ActiveState == "active"
90131

91132
- name: Ensure hypervisor has the right CRC IP
92133
become: true

0 commit comments

Comments
 (0)