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.5 KiB

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: clean hosts file
  11. lineinfile:
  12. dest: /etc/hosts
  13. regexp: "{{ item }}"
  14. state: absent
  15. with_items:
  16. - '^127\.0\.0\.1(\s+){{ inventory_hostname }}.*'
  17. - '^::1(\s+){{ inventory_hostname }}.*'
  18. - name: install dnsmasq and bindr9utils
  19. apt:
  20. name: "{{ item }}"
  21. state: present
  22. with_items:
  23. - dnsmasq
  24. - bind9utils
  25. when: inventory_hostname in groups['kube-master'][0]
  26. - name: ensure dnsmasq.d directory exists
  27. file:
  28. path: /etc/dnsmasq.d
  29. state: directory
  30. when: inventory_hostname in groups['kube-master'][0]
  31. - name: configure dnsmasq
  32. template:
  33. src: 01-kube-dns.conf.j2
  34. dest: /etc/dnsmasq.d/01-kube-dns.conf
  35. mode: 755
  36. notify:
  37. - restart dnsmasq
  38. when: inventory_hostname in groups['kube-master'][0]
  39. - name: enable dnsmasq
  40. service:
  41. name: dnsmasq
  42. state: started
  43. enabled: yes
  44. when: inventory_hostname in groups['kube-master'][0]
  45. - name: update resolv.conf with new DNS setup
  46. template:
  47. src: resolv.conf.j2
  48. dest: /etc/resolv.conf
  49. mode: 644
  50. - name: disable resolv.conf modification by dhclient
  51. copy: src=dhclient_nodnsupdate dest=/etc/dhcp/dhclient-enter-hooks.d/nodnsupdate mode=u+x