8025-awxRefactor-debianBootStrap #30

Merged
juan merged 37 commits from 8025-awxRefactor-debianBootStrap into main 2024-10-16 14:49:33 +00:00
2 changed files with 19 additions and 4 deletions
Showing only changes of commit d6c51141bf - Show all commits

View File

@ -4,3 +4,5 @@
tags: sysctl
- import_tasks: apparmor.yml
tags: apparmor
- import_tasks: resolv.yml
tags: resolv

View File

@ -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:
src: resolv.conf
dest: /etc/
src: templates/resolv.conf
dest: /etc/resolv.conf
owner: root
group: root
mode: '0644'
backup: true
when: resolv_enabled
when: not resolv_conf.stat.exists or not dns_configured