You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
3.4 KiB

  1. ---
  2. - name: check resolvconf
  3. shell: which resolvconf
  4. register: resolvconf
  5. failed_when: false
  6. changed_when: false
  7. - set_fact:
  8. resolvconf: >-
  9. {%- if resolvconf.rc == 0 -%}true{%- else -%}false{%- endif -%}
  10. - set_fact:
  11. bogus_domains: |-
  12. {% for d in [ 'default.svc.' + dns_domain, 'svc.' + dns_domain ] + searchdomains|default([]) -%}
  13. {{dns_domain}}.{{d}}./{{d}}.{{d}}./com.{{d}}./
  14. {%- endfor %}
  15. default_resolver: >-
  16. {%- if cloud_provider is defined and cloud_provider == 'gce' -%}169.254.169.254{%- else -%}8.8.8.8{%- endif -%}
  17. - name: check if kubelet is configured
  18. stat:
  19. path: "{{ kube_config_dir }}/kubelet.env"
  20. register: kubelet_configured
  21. changed_when: false
  22. - name: check if early DNS configuration stage
  23. set_fact:
  24. dns_early: >-
  25. {%- if kubelet_configured.stat.exists -%}false{%- else -%}true{%- endif -%}
  26. - name: target resolv.conf files
  27. set_fact:
  28. resolvconffile: /etc/resolv.conf
  29. base: >-
  30. {%- if resolvconf|bool -%}/etc/resolvconf/resolv.conf.d/base{%- endif -%}
  31. head: >-
  32. {%- if resolvconf|bool -%}/etc/resolvconf/resolv.conf.d/head{%- endif -%}
  33. when: not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
  34. - name: target temporary resolvconf cloud init file (Container Linux by CoreOS)
  35. set_fact: resolvconffile=/tmp/resolveconf_cloud_init_conf
  36. when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
  37. - name: check if /etc/dhclient.conf exists
  38. stat: path=/etc/dhclient.conf
  39. register: dhclient_stat
  40. - name: target dhclient conf file for /etc/dhclient.conf
  41. set_fact:
  42. dhclientconffile: /etc/dhclient.conf
  43. when: dhclient_stat.stat.exists
  44. - name: check if /etc/dhcp/dhclient.conf exists
  45. stat: path=/etc/dhcp/dhclient.conf
  46. register: dhcp_dhclient_stat
  47. - name: target dhclient conf file for /etc/dhcp/dhclient.conf
  48. set_fact:
  49. dhclientconffile: /etc/dhcp/dhclient.conf
  50. when: dhcp_dhclient_stat.stat.exists
  51. - name: target dhclient hook file for Red Hat family
  52. set_fact:
  53. dhclienthookfile: /etc/dhcp/dhclient.d/zdnsupdate.sh
  54. when: ansible_os_family == "RedHat"
  55. - name: target dhclient hook file for Debian family
  56. set_fact:
  57. dhclienthookfile: /etc/dhcp/dhclient-exit-hooks.d/zdnsupdate
  58. when: ansible_os_family == "Debian"
  59. - name: generate search domains to resolvconf
  60. set_fact:
  61. searchentries:
  62. search {{ ([ 'default.svc.' + dns_domain, 'svc.' + dns_domain ] + searchdomains|default([])) | join(' ') }}
  63. domainentry:
  64. domain {{ dns_domain }}
  65. supersede_search:
  66. supersede domain-search "{{ ([ 'default.svc.' + dns_domain, 'svc.' + dns_domain ] + searchdomains|default([])) | join('", "') }}";
  67. supersede_domain:
  68. supersede domain-name "{{ dns_domain }}";
  69. - name: pick dnsmasq cluster IP or default resolver
  70. set_fact:
  71. dnsmasq_server: |-
  72. {%- if dns_mode == 'kubedns' and not dns_early|bool -%}
  73. {{ [ skydns_server ] + upstream_dns_servers|default([]) }}
  74. {%- elif dns_early|bool -%}
  75. {{ upstream_dns_servers|default([]) }}
  76. {%- else -%}
  77. {{ [ dns_server ] }}
  78. {%- endif -%}
  79. - name: generate nameservers to resolvconf
  80. set_fact:
  81. nameserverentries:
  82. nameserver {{( dnsmasq_server + nameservers|default([default_resolver])) | join(',nameserver ')}}
  83. supersede_nameserver:
  84. supersede domain-name-servers {{( dnsmasq_server + nameservers|default([default_resolver])) | join(', ') }};