diff --git a/roles/kubernetes/preinstall/tasks/0020-set_facts.yml b/roles/kubernetes/preinstall/tasks/0020-set_facts.yml index 4541c14c5..ea0b8849f 100644 --- a/roles/kubernetes/preinstall/tasks/0020-set_facts.yml +++ b/roles/kubernetes/preinstall/tasks/0020-set_facts.yml @@ -185,8 +185,8 @@ set_fact: nameserverentries: |- {{ (([nodelocaldns_ip] if enable_nodelocaldns else []) + (coredns_server | d([]) if not enable_nodelocaldns else []) + nameservers | d([]) + cloud_resolver | d([]) + (configured_nameservers | d([]) if not disable_host_nameservers | d() | bool else [])) | unique | join(',') }} - supersede_nameserver: - supersede domain-name-servers {{ (([nodelocaldns_ip] if enable_nodelocaldns else []) + (coredns_server | d([]) if not enable_nodelocaldns else []) + nameservers | d([]) + cloud_resolver | d([]) + (configured_nameservers | d([]) if not disable_host_nameservers | d() | bool else [])) | unique | join(', ') }}; + dhclient_supersede_nameserver_entries_list: |- + {{ (([nodelocaldns_ip] if enable_nodelocaldns else []) + (coredns_server | d([]) if not enable_nodelocaldns else []) + nameservers | d([]) + cloud_resolver | d([]) + (configured_nameservers | d([]) if not disable_host_nameservers | d() | bool else [])) | unique }} when: not dns_early or dns_late # This task should run instead of the above task when cluster/nodelocal DNS hasn't @@ -195,10 +195,17 @@ set_fact: nameserverentries: |- {{ (nameservers | d([]) + cloud_resolver | d([]) + configured_nameservers | d([])) | unique | join(',') }} - supersede_nameserver: - supersede domain-name-servers {{ (nameservers | d([]) + cloud_resolver | d([])) | unique | join(', ') }}; + dhclient_supersede_nameserver_entries_list: |- + {{ (nameservers | d([]) + cloud_resolver | d([])) | unique }} when: dns_early and not dns_late +- name: Generate supersede_nameserver from dhclient_supersede_nameserver_entries_list + set_fact: + supersede_nameserver: |- + {%- if dhclient_supersede_nameserver_entries_list | length > 0 -%} + supersede domain-name-servers {{ dhclient_supersede_nameserver_entries_list | join(', ') }}; + {%- endif -%} + - name: Set etcd vars if using kubeadm mode set_fact: etcd_cert_dir: "{{ kube_cert_dir }}" diff --git a/roles/kubernetes/preinstall/tasks/0100-dhclient-hooks.yml b/roles/kubernetes/preinstall/tasks/0100-dhclient-hooks.yml index 480edc86b..6276034d3 100644 --- a/roles/kubernetes/preinstall/tasks/0100-dhclient-hooks.yml +++ b/roles/kubernetes/preinstall/tasks/0100-dhclient-hooks.yml @@ -2,7 +2,7 @@ - name: Configure dhclient to supersede search/domain/nameservers blockinfile: block: |- - {% for item in [supersede_domain, supersede_search, supersede_nameserver] -%} + {% for item in [supersede_domain, supersede_search, supersede_nameserver] | reject('equalto', '') -%} {{ item }} {% endfor %} path: "{{ dhclientconffile }}"