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.

75 lines
2.3 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. - name: Stat dnsmasq configuration
  30. stat: path=/etc/dnsmasq.d/01-kube-dns.conf
  31. register: sym
  32. - name: Move previous configuration
  33. command: mv /etc/dnsmasq.d/01-kube-dns.conf /etc/dnsmasq.d-available/01-kube-dns.conf.bak
  34. changed_when: False
  35. when: sym.stat.islnk is defined and sym.stat.islnk == False
  36. - name: Enable dnsmasq configuration
  37. file:
  38. src: /etc/dnsmasq.d-available/01-kube-dns.conf
  39. dest: /etc/dnsmasq.d/01-kube-dns.conf
  40. state: link
  41. - name: Create dnsmasq manifests
  42. template: src={{item.file}} dest={{kube_config_dir}}/{{item.file}}
  43. with_items:
  44. - {file: dnsmasq-ds.yml, type: ds}
  45. - {file: dnsmasq-svc.yml, type: svc}
  46. register: manifests
  47. when: inventory_hostname == groups['kube-master'][0]
  48. - name: Start Resources
  49. kube:
  50. name: dnsmasq
  51. namespace: "{{system_namespace}}"
  52. kubectl: "{{bin_dir}}/kubectl"
  53. resource: "{{item.item.type}}"
  54. filename: "{{kube_config_dir}}/{{item.item.file}}"
  55. state: "{{item.changed | ternary('latest','present') }}"
  56. with_items: "{{ manifests.results }}"
  57. when: inventory_hostname == groups['kube-master'][0]
  58. - name: Check for dnsmasq port (pulling image and running container)
  59. wait_for:
  60. host: "{{dns_server}}"
  61. port: 53
  62. delay: 5
  63. when: inventory_hostname == groups['kube-node'][0]
  64. tags: facts