Skip to content

Commit

Permalink
add-check-for-resolv-to-avoid-coredns-crash
Browse files Browse the repository at this point in the history
  • Loading branch information
yankay committed Nov 18, 2022
1 parent b9a6904 commit d3fcf1c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion roles/kubernetes/preinstall/tasks/0040-set_facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,21 @@

- name: get currently configured nameservers
set_fact:
configured_nameservers: "{{ resolvconf_slurp.content | b64decode | regex_findall('\\s*nameserver\\s*(.*)') | ipaddr }}"
configured_nameservers: "{{ resolvconf_slurp.content | b64decode | regex_findall('^nameserver\\s*(.*)', multiline=True) | ipaddr }}"
when: resolvconf_slurp.content is defined

when: resolvconf_stat.stat.exists is defined and resolvconf_stat.stat.exists

- name: Stop if /etc/resolv.conf not configured nameservers
assert:
that: configured_nameservers|length>0
fail_msg: "nameserver should not empty in /etc/resolv.conf"
when:
- not ignore_assert_errors
- configured_nameservers is defined
- not (upstream_dns_servers is defined and upstream_dns_servers|length > 0)
- not (disable_host_nameservers | default(false))

- name: NetworkManager | Check if host has NetworkManager
# noqa 303 Should we use service_facts for this?
command: systemctl is-active --quiet NetworkManager.service
Expand Down

0 comments on commit d3fcf1c

Please sign in to comment.