This commit is contained in:
1 parent
53a243a9a8
commit
6f3911a433
3 files changed
+41
No files matched your search
@@ -0,0 +1,7 @@
|
|||||||
|
- name: host maintenance - setup resolv.conf
|
||||||
|
hosts: '{{target|default("all")}}'
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- ansible.builtin.include_role:
|
||||||
|
name: mylimbo.globals.host_maintenance
|
||||||
|
tasks_from: resolv_conf
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# source https://oneuptime.com/blog/post/2026-02-21-how-to-use-ansible-to-manage-etc-resolv-conf/view
|
||||||
|
# vars:
|
||||||
|
# resolv_conf:
|
||||||
|
# nameservers:
|
||||||
|
# - x.x.x.x
|
||||||
|
# search_domains:
|
||||||
|
# - local.lan
|
||||||
|
- name: Deploy resolv.conf
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: templates/resolv.conf.j2
|
||||||
|
dest: /etc/resolv.conf
|
||||||
|
mode: '0644'
|
||||||
|
when: "resolv_conf is defined"
|
||||||
|
|
||||||
|
# todo tasks:
|
||||||
|
# systemd-resolvd:systemctl restart systemd-resolved
|
||||||
|
# clear cache: resolvectl flush-caches
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# templates/resolv.conf.j2
|
||||||
|
# Managed by Ansible - DO NOT EDIT MANUALLY
|
||||||
|
# Changes will be overwritten on next Ansible run
|
||||||
|
|
||||||
|
{% if resolv_conf.nameservers is defined and resolv_conf.nameservers | length > 0 %}
|
||||||
|
{% for ns in resolv_conf.nameservers %}
|
||||||
|
nameserver {{ ns }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if resolv_conf.search_domains is defined and resolv_conf.search_domains | length > 0 %}
|
||||||
|
search {{ resolv_conf.search_domains | join(' ') }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if resolv_conf.resolver_options is defined and resolv_conf.resolver_options | length > 0 %}
|
||||||
|
options {{ resolv_conf.resolver_options | join(' ') }}
|
||||||
|
{% endif %}
|
||||||
Reference in new issue
Block a user