Merge pull request #986 from vwfs/dnsmasq_system_nameservers

Also add the system nameservers to upstream servers in dnsmasq
This commit is contained in:
Antoine Legrand 2017-02-08 23:21:54 +01:00 committed by GitHub
commit 68df0d4909
2 changed files with 17 additions and 4 deletions

View file

@ -11,6 +11,20 @@
state: directory
tags: bootstrap-os
- name: check system nameservers
shell: awk '/^nameserver/ {print $NF}' /etc/resolv.conf
changed_when: False
register: system_nameservers
- name: init system_and_upstream_dns_servers
set_fact:
system_and_upstream_dns_servers: "{{ upstream_dns_servers|default([]) }}"
- name: combine upstream_dns_servers and system nameservers (only for docker_dns)
set_fact:
system_and_upstream_dns_servers: "{{ system_and_upstream_dns_servers | union(system_nameservers.stdout_lines) | unique }}"
when: system_nameservers.stdout != "" and resolvconf_mode != 'host_resolvconf'
- name: Write dnsmasq configuration
template:
src: 01-kube-dns.conf.j2

View file

@ -11,20 +11,19 @@ server=/{{ dns_domain }}/{{ skydns_server }}
local=/{{ bogus_domains }}
#Set upstream dns servers
{% if upstream_dns_servers is defined %}
{% for srv in upstream_dns_servers %}
{% if system_and_upstream_dns_servers|length > 0 %}
{% for srv in system_and_upstream_dns_servers %}
server={{ srv }}
{% endfor %}
no-resolv
{% elif resolvconf_mode == 'host_resolvconf' %}
{# The default resolver is only needed when the hosts resolv.conf was modified by us. If it was not modified, we can rely on dnsmasq to reuse the systems resolv.conf #}
server={{ default_resolver }}
no-resolv
{% endif %}
{% if kube_log_level == '4' %}
log-queries
{% endif %}
no-resolv
bogus-priv
no-negcache
cache-size={{ cache_size }}