Merge pull request #649 from bogdando/coreos_resolvconf

Ensure /etc/resolv.conf content for CoreOS
pull/651/head
Smaine Kahlouch 2016-11-24 10:42:38 +01:00 committed by GitHub
commit f6c32c3ea3
4 changed files with 50 additions and 0 deletions

View File

@ -11,6 +11,10 @@
#nameservers: #nameservers:
# - 127.0.0.1 # - 127.0.0.1
# CoreOS cloud init config file to define /etc/resolv.conf content
# for hostnet pods and infra needs
resolveconf_cloud_init_conf: /etc/resolveconf_cloud_init.conf
# Versions # Versions
dnsmasq_version: 2.72 dnsmasq_version: 2.72

View File

@ -21,11 +21,23 @@
notify: notify:
- Dnsmasq | reload resolvconf - Dnsmasq | reload resolvconf
- Dnsmasq | reload kubelet - Dnsmasq | reload kubelet
when: ansible_os_family != "CoreOS"
- name: Dnsmasq | update resolvconf for CoreOS
command: /bin/true
notify:
- Dnsmasq | apply resolvconf cloud-init
- Dnsmasq | reload kubelet
when: ansible_os_family == "CoreOS"
- name: Dnsmasq | reload resolvconf - name: Dnsmasq | reload resolvconf
command: /sbin/resolvconf -u command: /sbin/resolvconf -u
ignore_errors: true ignore_errors: true
- name: Dnsmasq | apply resolvconf cloud-init
command: /usr/bin/coreos-cloudinit --from-file {{ resolveconf_cloud_init_conf }}
when: ansible_os_family == "CoreOS"
- name: Dnsmasq | reload kubelet - name: Dnsmasq | reload kubelet
service: service:
name: kubelet name: kubelet

View File

@ -9,6 +9,16 @@
set_fact: set_fact:
resolvconffile: >- resolvconffile: >-
{%- if resolvconf.rc == 0 -%}/etc/resolvconf/resolv.conf.d/head{%- else -%}/etc/resolv.conf{%- endif -%} {%- if resolvconf.rc == 0 -%}/etc/resolvconf/resolv.conf.d/head{%- else -%}/etc/resolv.conf{%- endif -%}
when: ansible_os_family != "CoreOS"
- name: target temporary resolvconf cloud init file
set_fact:
resolvconffile: /tmp/resolveconf_cloud_init_conf
when: ansible_os_family == "CoreOS"
- name: create temporary resolveconf cloud init file
command: cp -f /etc/resolv.conf "{{ resolvconffile }}"
when: ansible_os_family == "CoreOS"
- name: generate search domains to resolvconf - name: generate search domains to resolvconf
set_fact: set_fact:
@ -100,3 +110,17 @@
copy: src=dhclient_nodnsupdate dest=/etc/dhcp/dhclient.d/nodnsupdate mode=u+x copy: src=dhclient_nodnsupdate dest=/etc/dhcp/dhclient.d/nodnsupdate mode=u+x
notify: Dnsmasq | restart network notify: Dnsmasq | restart network
when: ansible_os_family == "RedHat" when: ansible_os_family == "RedHat"
- name: get temporary resolveconf cloud init file content
command: cat {{ resolvconffile }}
register: cloud_config
when: ansible_os_family == "CoreOS"
- name: persist resolvconf cloud init file
template:
dest: "{{resolveconf_cloud_init_conf}}"
src: resolvconf.j2
owner: root
mode: 0644
notify: Dnsmasq | update resolvconf for CoreOS
when: ansible_os_family == "CoreOS"

View File

@ -0,0 +1,10 @@
#cloud-config
write_files:
- path: "/etc/resolv.conf"
permissions: "0644"
owner: "root"
content: |
{% for l in cloud_config.stdout_lines %}
{{ l }}
{% endfor %}
#