Refs #8025 Solution to approach resolv.conf only on case no dhcp-client is used
This commit is contained in:
parent
757d3dfe29
commit
d6c51141bf
|
@ -4,3 +4,5 @@
|
||||||
tags: sysctl
|
tags: sysctl
|
||||||
- import_tasks: apparmor.yml
|
- import_tasks: apparmor.yml
|
||||||
tags: apparmor
|
tags: apparmor
|
||||||
|
- import_tasks: resolv.yml
|
||||||
|
tags: resolv
|
||||||
|
|
|
@ -1,9 +1,22 @@
|
||||||
- name: Replace /etc/resolv.conf
|
- name: Check if DNS is already configured
|
||||||
|
stat:
|
||||||
|
path: /etc/resolv.conf
|
||||||
|
register: resolv_conf
|
||||||
|
- name: Read /etc/resolv.conf
|
||||||
|
slurp:
|
||||||
|
path: /etc/resolv.conf
|
||||||
|
register: resolv_conf_content
|
||||||
|
when: resolv_conf.stat.exists
|
||||||
|
- name: Check if DNS servers are already present
|
||||||
|
set_fact:
|
||||||
|
dns_configured: "{{ resolv_conf_content['content'] | b64decode | regex_search('^nameserver') is not none }}"
|
||||||
|
when: resolv_conf.stat.exists
|
||||||
|
- name: Apply resolv.conf template only if DNS is not configured
|
||||||
template:
|
template:
|
||||||
src: resolv.conf
|
src: templates/resolv.conf
|
||||||
dest: /etc/
|
dest: /etc/resolv.conf
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: '0644'
|
mode: '0644'
|
||||||
backup: true
|
backup: true
|
||||||
when: resolv_enabled
|
when: not resolv_conf.stat.exists or not dns_configured
|
||||||
|
|
Loading…
Reference in New Issue