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.

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