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.

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