dnsmasq with multi master arch

pull/22/head
Smaine Kahlouch 2015-12-11 11:48:43 +01:00
parent 3981b73924
commit b23b8aa3de
2 changed files with 11 additions and 4 deletions

View File

@ -21,16 +21,17 @@
apt: apt:
name: "{{ item }}" name: "{{ item }}"
state: present state: present
update_cache: yes
with_items: with_items:
- dnsmasq - dnsmasq
- bind9utils - bind9utils
when: inventory_hostname in groups['kube-master'][0] when: inventory_hostname in groups['kube-master']
- name: ensure dnsmasq.d directory exists - name: ensure dnsmasq.d directory exists
file: file:
path: /etc/dnsmasq.d path: /etc/dnsmasq.d
state: directory state: directory
when: inventory_hostname in groups['kube-master'][0] when: inventory_hostname in groups['kube-master']
- name: configure dnsmasq - name: configure dnsmasq
template: template:
@ -39,14 +40,14 @@
mode: 755 mode: 755
notify: notify:
- restart dnsmasq - restart dnsmasq
when: inventory_hostname in groups['kube-master'][0] when: inventory_hostname in groups['kube-master']
- name: enable dnsmasq - name: enable dnsmasq
service: service:
name: dnsmasq name: dnsmasq
state: started state: started
enabled: yes enabled: yes
when: inventory_hostname in groups['kube-master'][0] when: inventory_hostname in groups['kube-master']
- name: update resolv.conf with new DNS setup - name: update resolv.conf with new DNS setup
template: template:
@ -56,3 +57,5 @@
- name: disable resolv.conf modification by dhclient - name: disable resolv.conf modification by dhclient
copy: src=dhclient_nodnsupdate dest=/etc/dhcp/dhclient-enter-hooks.d/nodnsupdate mode=u+x copy: src=dhclient_nodnsupdate dest=/etc/dhcp/dhclient-enter-hooks.d/nodnsupdate mode=u+x
- meta: flush_handlers

View File

@ -1,5 +1,9 @@
; generated by ansible ; generated by ansible
search {{ [ 'default.svc.' + dns_domain, 'svc.' + dns_domain, dns_domain ] | join(' ') }} search {{ [ 'default.svc.' + dns_domain, 'svc.' + dns_domain, dns_domain ] | join(' ') }}
{% if inventory_hostname in groups['kube-master'] %}
nameserver {{ ansible_default_ipv4.address }}
{% else %}
{% for host in groups['kube-master'] %} {% for host in groups['kube-master'] %}
nameserver {{ hostvars[host]['ansible_default_ipv4']['address'] }} nameserver {{ hostvars[host]['ansible_default_ipv4']['address'] }}
{% endfor %} {% endfor %}
{% endif %}