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.

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