Browse Source

Improve management of nameservers in resolv.conf

Changing nameservers now will clean up previous entries
pull/501/head
Matthew Mosesohn 8 years ago
parent
commit
d313be4420
1 changed files with 7 additions and 4 deletions
  1. 11
      roles/dnsmasq/tasks/main.yml

11
roles/dnsmasq/tasks/main.yml

@ -86,14 +86,17 @@
follow: yes follow: yes
- name: Add local dnsmasq to resolv.conf - name: Add local dnsmasq to resolv.conf
lineinfile:
line: "nameserver {{item}}"
blockinfile:
dest: "{{resolvconffile}}" dest: "{{resolvconffile}}"
block: |-
{% for item in nameserverentries -%}
nameserver {{ item }}
{% endfor %}
state: present state: present
insertafter: "^search.*$"
create: yes
backup: yes backup: yes
follow: yes follow: yes
with_items: "{{nameserverentries}}"
marker: "# Ansible nameservers {mark}"
- name: Add options to resolv.conf - name: Add options to resolv.conf
lineinfile: lineinfile:

Loading…
Cancel
Save