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.

69 lines
1.9 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. ---
  2. - name: populate inventory into hosts file
  3. lineinfile:
  4. dest: /etc/hosts
  5. regexp: "^{{ hostvars[item].ansible_default_ipv4.address }} {{ item }}$"
  6. line: "{{ hostvars[item].ansible_default_ipv4.address }} {{ item }}"
  7. state: present
  8. when: hostvars[item].ansible_default_ipv4.address is defined
  9. with_items: groups['all']
  10. - name: populate kubernetes loadbalancer address into hosts file
  11. lineinfile:
  12. dest: /etc/hosts
  13. regexp: ".*{{ apiserver_loadbalancer_domain_name }}$"
  14. line: "{{ loadbalancer_apiserver.address }} lb-apiserver.kubernetes.local"
  15. state: present
  16. when: loadbalancer_apiserver is defined and apiserver_loadbalancer_domain_name is defined
  17. - name: clean hosts file
  18. lineinfile:
  19. dest: /etc/hosts
  20. regexp: "{{ item }}"
  21. state: absent
  22. with_items:
  23. - '^127\.0\.0\.1(\s+){{ inventory_hostname }}.*'
  24. - '^::1(\s+){{ inventory_hostname }}.*'
  25. - name: install dnsmasq and bindr9utils
  26. apt:
  27. name: "{{ item }}"
  28. state: present
  29. update_cache: yes
  30. with_items:
  31. - dnsmasq
  32. - bind9utils
  33. when: inventory_hostname in groups['kube-master']
  34. - name: ensure dnsmasq.d directory exists
  35. file:
  36. path: /etc/dnsmasq.d
  37. state: directory
  38. when: inventory_hostname in groups['kube-master']
  39. - name: configure dnsmasq
  40. template:
  41. src: 01-kube-dns.conf.j2
  42. dest: /etc/dnsmasq.d/01-kube-dns.conf
  43. mode: 755
  44. notify:
  45. - restart dnsmasq
  46. when: inventory_hostname in groups['kube-master']
  47. - name: enable dnsmasq
  48. service:
  49. name: dnsmasq
  50. state: started
  51. enabled: yes
  52. when: inventory_hostname in groups['kube-master']
  53. - name: update resolv.conf with new DNS setup
  54. template:
  55. src: resolv.conf.j2
  56. dest: /etc/resolv.conf
  57. mode: 644
  58. - name: disable resolv.conf modification by dhclient
  59. copy: src=dhclient_nodnsupdate dest=/etc/dhcp/dhclient-enter-hooks.d/nodnsupdate mode=u+x
  60. - meta: flush_handlers