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.

82 lines
2.5 KiB

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