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.

58 lines
1.6 KiB

  1. ---
  2. - name: ensure dnsmasq.d directory exists
  3. file:
  4. path: /etc/dnsmasq.d
  5. state: directory
  6. - name: ensure dnsmasq.d-available directory exists
  7. file:
  8. path: /etc/dnsmasq.d-available
  9. state: directory
  10. - name: Write dnsmasq configuration
  11. template:
  12. src: 01-kube-dns.conf.j2
  13. dest: /etc/dnsmasq.d-available/01-kube-dns.conf
  14. mode: 0755
  15. backup: yes
  16. - name: Stat dnsmasq configuration
  17. stat: path=/etc/dnsmasq.d/01-kube-dns.conf
  18. register: sym
  19. - name: Move previous configuration
  20. command: mv /etc/dnsmasq.d/01-kube-dns.conf /etc/dnsmasq.d-available/01-kube-dns.conf.bak
  21. changed_when: False
  22. when: sym.stat.islnk is defined and sym.stat.islnk == False
  23. - name: Enable dnsmasq configuration
  24. file:
  25. src: /etc/dnsmasq.d-available/01-kube-dns.conf
  26. dest: /etc/dnsmasq.d/01-kube-dns.conf
  27. state: link
  28. - name: Create dnsmasq manifests
  29. template: src={{item.file}} dest=/etc/kubernetes/{{item.file}}
  30. with_items:
  31. - {file: dnsmasq-ds.yml, type: ds}
  32. - {file: dnsmasq-svc.yml, type: svc}
  33. register: manifests
  34. when: inventory_hostname == groups['kube-master'][0]
  35. - name: Start Resources
  36. kube:
  37. name: dnsmasq
  38. namespace: kube-system
  39. kubectl: "{{bin_dir}}/kubectl"
  40. resource: "{{item.item.type}}"
  41. filename: /etc/kubernetes/{{item.item.file}}
  42. state: "{{item.changed | ternary('latest','present') }}"
  43. with_items: "{{ manifests.results }}"
  44. when: inventory_hostname == groups['kube-master'][0]
  45. - name: Check for dnsmasq port (pulling image and running container)
  46. wait_for:
  47. host: "{{dns_server}}"
  48. port: 53
  49. delay: 5
  50. when: inventory_hostname == groups['kube-node'][0]