From 6450b85b835a83e541245f7abb9c7fcc8b991632 Mon Sep 17 00:00:00 2001 From: jwfang <54740235@qq.com> Date: Tue, 20 Jun 2017 20:06:54 +0800 Subject: [PATCH 1/3] make max docker dns server configurable --- inventory/group_vars/all.yml | 4 ++++ roles/docker/defaults/main.yml | 2 ++ roles/docker/tasks/set_facts_dns.yml | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/inventory/group_vars/all.yml b/inventory/group_vars/all.yml index 6388ca7af..999d554f2 100644 --- a/inventory/group_vars/all.yml +++ b/inventory/group_vars/all.yml @@ -83,6 +83,10 @@ bin_dir: /usr/local/bin ## Please note that overlay2 is only supported on newer kernels #docker_storage_options: -s overlay2 +# Maximum name servers for docker. If your host /etc/resolv.conf contains serval +# nameservers, you may need to increase this. +#docker_max_dns_servers: 3 + ## Default packages to install within the cluster, f.e: #kpm_packages: # - name: kube-system/grafana diff --git a/roles/docker/defaults/main.yml b/roles/docker/defaults/main.yml index c771953ff..ca88fa1f1 100644 --- a/roles/docker/defaults/main.yml +++ b/roles/docker/defaults/main.yml @@ -8,3 +8,5 @@ docker_repo_key_info: docker_repo_info: repos: + +docker_max_dns_servers: 3 diff --git a/roles/docker/tasks/set_facts_dns.yml b/roles/docker/tasks/set_facts_dns.yml index f17c1bde2..1823b489b 100644 --- a/roles/docker/tasks/set_facts_dns.yml +++ b/roles/docker/tasks/set_facts_dns.yml @@ -53,7 +53,7 @@ - name: check number of nameservers fail: msg: "Too many nameservers" - when: docker_dns_servers|length > 3 + when: docker_dns_servers|length > docker_max_dns_servers|int - name: check number of search domains fail: From 5fbb684cae7491139d84081d37a3fc57043fd121 Mon Sep 17 00:00:00 2001 From: jwfang <54740235@qq.com> Date: Thu, 22 Jun 2017 09:56:57 +0800 Subject: [PATCH 2/3] Revert "make max docker dns server configurable" This reverts commit 6450b85b835a83e541245f7abb9c7fcc8b991632. --- inventory/group_vars/all.yml | 4 ---- roles/docker/defaults/main.yml | 2 -- roles/docker/tasks/set_facts_dns.yml | 2 +- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/inventory/group_vars/all.yml b/inventory/group_vars/all.yml index 999d554f2..6388ca7af 100644 --- a/inventory/group_vars/all.yml +++ b/inventory/group_vars/all.yml @@ -83,10 +83,6 @@ bin_dir: /usr/local/bin ## Please note that overlay2 is only supported on newer kernels #docker_storage_options: -s overlay2 -# Maximum name servers for docker. If your host /etc/resolv.conf contains serval -# nameservers, you may need to increase this. -#docker_max_dns_servers: 3 - ## Default packages to install within the cluster, f.e: #kpm_packages: # - name: kube-system/grafana diff --git a/roles/docker/defaults/main.yml b/roles/docker/defaults/main.yml index ca88fa1f1..c771953ff 100644 --- a/roles/docker/defaults/main.yml +++ b/roles/docker/defaults/main.yml @@ -8,5 +8,3 @@ docker_repo_key_info: docker_repo_info: repos: - -docker_max_dns_servers: 3 diff --git a/roles/docker/tasks/set_facts_dns.yml b/roles/docker/tasks/set_facts_dns.yml index 1823b489b..f17c1bde2 100644 --- a/roles/docker/tasks/set_facts_dns.yml +++ b/roles/docker/tasks/set_facts_dns.yml @@ -53,7 +53,7 @@ - name: check number of nameservers fail: msg: "Too many nameservers" - when: docker_dns_servers|length > docker_max_dns_servers|int + when: docker_dns_servers|length > 3 - name: check number of search domains fail: From c96f679e821fd0f109d6e92f5ac2c31830a05f64 Mon Sep 17 00:00:00 2001 From: jwfang <54740235@qq.com> Date: Thu, 22 Jun 2017 10:56:21 +0800 Subject: [PATCH 3/3] docker_dns_servers_strict to control docker_dns_servers rtrim --- inventory/group_vars/all.yml | 3 +++ roles/docker/defaults/main.yml | 2 ++ roles/docker/tasks/set_facts_dns.yml | 9 +++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/inventory/group_vars/all.yml b/inventory/group_vars/all.yml index 6388ca7af..a30055367 100644 --- a/inventory/group_vars/all.yml +++ b/inventory/group_vars/all.yml @@ -83,6 +83,9 @@ bin_dir: /usr/local/bin ## Please note that overlay2 is only supported on newer kernels #docker_storage_options: -s overlay2 +# Uncomment this if you have more than 3 nameservers, then we'll only use the first 3. +#docker_dns_servers_strict: false + ## Default packages to install within the cluster, f.e: #kpm_packages: # - name: kube-system/grafana diff --git a/roles/docker/defaults/main.yml b/roles/docker/defaults/main.yml index c771953ff..e262d908a 100644 --- a/roles/docker/defaults/main.yml +++ b/roles/docker/defaults/main.yml @@ -8,3 +8,5 @@ docker_repo_key_info: docker_repo_info: repos: + +docker_dns_servers_strict: yes diff --git a/roles/docker/tasks/set_facts_dns.yml b/roles/docker/tasks/set_facts_dns.yml index f17c1bde2..64a09bff2 100644 --- a/roles/docker/tasks/set_facts_dns.yml +++ b/roles/docker/tasks/set_facts_dns.yml @@ -52,8 +52,13 @@ - name: check number of nameservers fail: - msg: "Too many nameservers" - when: docker_dns_servers|length > 3 + msg: "Too many nameservers. You can relax this check by set docker_dns_servers_strict=no and we will only use the first 3." + when: docker_dns_servers|length > 3 and docker_dns_servers_strict|bool + +- name: rtrim number of nameservers to 3 + set_fact: + docker_dns_servers: "{{ docker_dns_servers[0:3] }}" + when: docker_dns_servers|length > 3 and not docker_dns_servers_strict|bool - name: check number of search domains fail: