Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert dns defaults to list #519

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions defaults/main/dns.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
---
dns: 127.0.0.1 1.1.1.1
fallback_dns: 9.9.9.9 1.0.0.1
dns:
- 127.0.0.1
- 1.1.1.1
fallback_dns:
- 9.9.9.9
- 1.0.0.1
dnssec: allow-downgrade
dns_over_tls: opportunistic
4 changes: 2 additions & 2 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -736,8 +736,8 @@
failed_when: systemd_resolved_conf.rc != 0
changed_when: systemd_resolved_conf.rc != 0
with_items:
- DNS={{ dns }}
- FallbackDNS={{ fallback_dns }}
- DNS={{ dns | join(' ') }}
- FallbackDNS={{ fallback_dns | join(' ') }}
- DNSSEC={{ dnssec }}
- DNSOverTLS={{ dns_over_tls }}
when:
Expand Down
6 changes: 5 additions & 1 deletion tasks/resolvedconf.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---
- name: Merge all DNS servers
ansible.builtin.set_fact:
dns_merged: "{{ dns + fallback_dns }}"

- name: Configure systemd resolved
become: true
ansible.builtin.template:
Expand All @@ -24,7 +28,7 @@
owner: root
group: root
state: present
loop: "{{ dns | split }}"
loop: "{{ dns_merged | sort | unique }}"
when:
- ansible_os_family == "RedHat"
tags:
Expand Down
4 changes: 2 additions & 2 deletions templates/etc/systemd/resolved.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Generated by Ansible role {{ ansible_role_name }}

[Resolve]
DNS={{ dns }}
FallbackDNS={{ fallback_dns }}
DNS={{ dns | join(' ') }}
FallbackDNS={{ fallback_dns | join(' ') }}
DNSSEC={{ dnssec }}
{% if ansible_local.systemd.version | int >= 239 %}
DNSOverTLS={{ dns_over_tls }}
Expand Down
Loading