From 30d9882851945f7b0588680b57c7576a23495818 Mon Sep 17 00:00:00 2001 From: Alvaro Campesino <57360851+Alvaro-Campesino@users.noreply.github.com> Date: Sat, 4 Dec 2021 05:36:31 +0100 Subject: [PATCH] Add nodelocaldns only if it is enabled (#7731) --- roles/kubernetes/preinstall/tasks/0040-set_facts.yml | 2 +- roles/kubernetes/preinstall/templates/resolved.conf.j2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/kubernetes/preinstall/tasks/0040-set_facts.yml b/roles/kubernetes/preinstall/tasks/0040-set_facts.yml index 75c753c38..cf6612b00 100644 --- a/roles/kubernetes/preinstall/tasks/0040-set_facts.yml +++ b/roles/kubernetes/preinstall/tasks/0040-set_facts.yml @@ -147,7 +147,7 @@ - name: generate nameservers to resolvconf set_fact: nameserverentries: - nameserver {{ ( coredns_server|d([]) + nameservers|d([]) + cloud_resolver|d([])) | unique | join(',nameserver ') }} + nameserver {{ ( ( [nodelocaldns_ip] if enable_nodelocaldns else []) + coredns_server|d([]) + nameservers|d([]) + cloud_resolver|d([])) | unique | join(',nameserver ') }} supersede_nameserver: supersede domain-name-servers {{ ( coredns_server|d([]) + nameservers|d([]) + cloud_resolver|d([])) | unique | join(', ') }}; diff --git a/roles/kubernetes/preinstall/templates/resolved.conf.j2 b/roles/kubernetes/preinstall/templates/resolved.conf.j2 index 57e6d6348..1858d4923 100644 --- a/roles/kubernetes/preinstall/templates/resolved.conf.j2 +++ b/roles/kubernetes/preinstall/templates/resolved.conf.j2 @@ -1,5 +1,5 @@ [Resolve] -DNS={{ coredns_server | list | join(' ') }} +DNS={{ (nodelocaldns_ip |default(coredns_server) )| list | join(' ') }} FallbackDNS={{ ( nameservers|d([]) + cloud_resolver|d([])) | unique | join(' ') }} Domains={{ ([ 'default.svc.' + dns_domain, 'svc.' + dns_domain ] + searchdomains|default([])) | join(' ') }} #LLMNR=no