From e26d5dfc2738fc1472cfcf618e1e6b408734ea90 Mon Sep 17 00:00:00 2001 From: Jeltz Date: Fri, 26 Aug 2022 19:11:40 +0200 Subject: [PATCH] resolvconf: add role --- roles/resolvconf/tasks/main.yml | 9 +++++++++ roles/resolvconf/templates/resolv.conf.j2 | 11 +++++++++++ 2 files changed, 20 insertions(+) create mode 100644 roles/resolvconf/tasks/main.yml create mode 100644 roles/resolvconf/templates/resolv.conf.j2 diff --git a/roles/resolvconf/tasks/main.yml b/roles/resolvconf/tasks/main.yml new file mode 100644 index 0000000..d650b78 --- /dev/null +++ b/roles/resolvconf/tasks/main.yml @@ -0,0 +1,9 @@ +--- +- name: Install resolv.conf + template: + src: resolv.conf.j2 + dest: /etc/resolv.conf + owner: root + group: root + mode: u=rw,g=r,o=r +... diff --git a/roles/resolvconf/templates/resolv.conf.j2 b/roles/resolvconf/templates/resolv.conf.j2 new file mode 100644 index 0000000..9376000 --- /dev/null +++ b/roles/resolvconf/templates/resolv.conf.j2 @@ -0,0 +1,11 @@ +{{ ansible_managed | comment }} + +{% for nameserver in resolvconf__nameservers %} +nameserver {{ nameserver | ipaddr }} +{% endfor %} +{% if resolvconf__domain is defined %} +domain {{ resolvconf__domain }} +{% endif %} +{% if resolvconf__search is defined %} +search {{ resolvconf__search | join(" ") }} +{% endif %}