Browse Source

Add nameserver role

samba
Victor LABORIE 4 years ago
parent
commit
0c5cc59bc6
  1. 13
      nameserver/README.md
  2. 27
      nameserver/tasks/main.yml

13
nameserver/README.md

@ -0,0 +1,13 @@
# nameserver
Set nameserver in /etc/resolv.conf.
## Tasks
Everything is in the `tasks/main.yml` file.
## Available variables
Main variables are :
* `nameservers` : list of IP addresses of DNS servers ;

27
nameserver/tasks/main.yml

@ -0,0 +1,27 @@
---
- name: Get actual nameserver
shell: grep nameserver /etc/resolv.conf | awk '{ print $2 }'
register: grep_nameserver
check_mode: no
changed_when: false
tags:
- nameserver
- name: Set nameserver
lineinfile:
dest: /etc/resolv.conf
line: "nameserver {{ item }}"
state: present
with_items: "{{ nameservers }}"
tags:
- nameserver
- name: Unset others nameserver
lineinfile:
dest: /etc/resolv.conf
line: "nameserver {{ item }}"
state: absent
with_items: "{{ grep_nameserver.stdout_lines }}"
when: item not in nameservers
tags:
- nameserver
Loading…
Cancel
Save