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.

75 lines
2.0 KiB

9 years ago
9 years ago
9 years ago
9 years ago
8 years ago
9 years ago
9 years ago
9 years ago
  1. ---
  2. - name: ensure dnsmasq.d directory exists
  3. file:
  4. path: /etc/dnsmasq.d
  5. state: directory
  6. - name: Write dnsmasq configuration
  7. template:
  8. src: 01-kube-dns.conf.j2
  9. dest: /etc/dnsmasq.d/01-kube-dns.conf
  10. mode: 755
  11. backup: yes
  12. - name: Create dnsmasq pod manifest
  13. template: src=dnsmasq-pod.yml dest=/etc/kubernetes/manifests/dnsmasq-pod.manifest
  14. - name: Check for dnsmasq port (pulling image and running container)
  15. wait_for:
  16. port: 53
  17. delay: 5
  18. - name: check resolvconf
  19. stat: path=/etc/resolvconf/resolv.conf.d/head
  20. register: resolvconf
  21. - name: target resolv.conf file
  22. set_fact:
  23. resolvconffile: >-
  24. {%- if resolvconf.stat.exists == True -%}/etc/resolvconf/resolv.conf.d/head{%- else -%}/etc/resolv.conf{%- endif -%}
  25. - name: Add search resolv.conf
  26. lineinfile:
  27. line: "search {{ [ 'default.svc.' + dns_domain, 'svc.' + dns_domain, dns_domain ] | join(' ') }}"
  28. dest: "{{resolvconffile}}"
  29. state: present
  30. insertbefore: BOF
  31. backup: yes
  32. follow: yes
  33. - name: Add local dnsmasq to resolv.conf
  34. lineinfile:
  35. line: "nameserver 127.0.0.1"
  36. dest: "{{resolvconffile}}"
  37. state: present
  38. insertafter: "^search.*$"
  39. backup: yes
  40. follow: yes
  41. - name: Add options to resolv.conf
  42. lineinfile:
  43. line: options {{ item }}
  44. dest: "{{resolvconffile}}"
  45. state: present
  46. regexp: "^options.*{{ item }}$"
  47. insertafter: EOF
  48. backup: yes
  49. follow: yes
  50. with_items:
  51. - timeout:2
  52. - attempts:2
  53. - name: disable resolv.conf modification by dhclient
  54. copy: src=dhclient_nodnsupdate dest=/etc/dhcp/dhclient-enter-hooks.d/nodnsupdate mode=u+x backup=yes
  55. when: ansible_os_family == "Debian"
  56. - name: disable resolv.conf modification by dhclient
  57. copy: src=dhclient_nodnsupdate dest=/etc/dhcp/dhclient.d/nodnsupdate mode=u+x backup=yes
  58. when: ansible_os_family == "RedHat"
  59. - name: update resolvconf
  60. command: resolvconf -u
  61. changed_when: False
  62. when: resolvconf.stat.exists == True
  63. - meta: flush_handlers