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.

87 lines
2.8 KiB

9 years ago
9 years ago
  1. ---
  2. - name: ensure dnsmasq.d directory exists
  3. file:
  4. path: /etc/dnsmasq.d
  5. state: directory
  6. tags: bootstrap-os
  7. - name: ensure dnsmasq.d-available directory exists
  8. file:
  9. path: /etc/dnsmasq.d-available
  10. state: directory
  11. tags: bootstrap-os
  12. - name: check system nameservers
  13. shell: awk '/^nameserver/ {print $NF}' /etc/resolv.conf
  14. changed_when: False
  15. register: system_nameservers
  16. - name: init system_and_upstream_dns_servers
  17. set_fact:
  18. system_and_upstream_dns_servers: "{{ upstream_dns_servers|default([]) }}"
  19. - name: combine upstream_dns_servers and system nameservers (only for docker_dns)
  20. set_fact:
  21. system_and_upstream_dns_servers: "{{ system_and_upstream_dns_servers | union(system_nameservers.stdout_lines) | unique }}"
  22. when: system_nameservers.stdout != "" and resolvconf_mode != 'host_resolvconf'
  23. - name: Write dnsmasq configuration
  24. template:
  25. src: 01-kube-dns.conf.j2
  26. dest: /etc/dnsmasq.d-available/01-kube-dns.conf
  27. mode: 0755
  28. backup: yes
  29. register: dnsmasq_config
  30. - name: Stat dnsmasq configuration
  31. stat: path=/etc/dnsmasq.d/01-kube-dns.conf
  32. register: sym
  33. - name: Move previous configuration
  34. command: mv /etc/dnsmasq.d/01-kube-dns.conf /etc/dnsmasq.d-available/01-kube-dns.conf.bak
  35. changed_when: False
  36. when: sym.stat.islnk is defined and sym.stat.islnk == False
  37. - name: Enable dnsmasq configuration
  38. file:
  39. src: /etc/dnsmasq.d-available/01-kube-dns.conf
  40. dest: /etc/dnsmasq.d/01-kube-dns.conf
  41. state: link
  42. - name: Create dnsmasq manifests
  43. template: src={{item.file}} dest={{kube_config_dir}}/{{item.file}}
  44. with_items:
  45. - {file: dnsmasq-ds.yml, type: ds}
  46. - {file: dnsmasq-svc.yml, type: svc}
  47. register: manifests
  48. when: inventory_hostname == groups['kube-master'][0]
  49. #FIXME: remove manifests.changed condition if kubernetes/features#124 is implemented
  50. - name: Delete existing dnsmasq daemonset
  51. kube:
  52. name: dnsmasq
  53. namespace: "{{system_namespace}}"
  54. kubectl: "{{bin_dir}}/kubectl"
  55. resource: "ds"
  56. filename: "{{kube_config_dir}}/{{item.item.file}}"
  57. state: absent
  58. with_items: "{{ manifests.results }}"
  59. when: inventory_hostname == groups['kube-master'][0] and item.item.type == "ds" and (manifests.changed or dnsmasq_config.changed)
  60. - name: Start Resources
  61. kube:
  62. name: dnsmasq
  63. namespace: "{{system_namespace}}"
  64. kubectl: "{{bin_dir}}/kubectl"
  65. resource: "{{item.item.type}}"
  66. filename: "{{kube_config_dir}}/{{item.item.file}}"
  67. state: "{{item.changed | ternary('latest','present') }}"
  68. with_items: "{{ manifests.results }}"
  69. when: inventory_hostname == groups['kube-master'][0]
  70. - name: Check for dnsmasq port (pulling image and running container)
  71. wait_for:
  72. host: "{{dns_server}}"
  73. port: 53
  74. delay: 5
  75. when: inventory_hostname == groups['kube-node'][0]