feat(resolved): add role

This commit is contained in:
Lukas Lihotzki 2024-10-09 19:11:19 +02:00
parent 66ef48220e
commit 261aefc9af
No known key found for this signature in database
GPG key ID: 77A482FBA7402182
4 changed files with 50 additions and 0 deletions

View file

@ -0,0 +1,6 @@
---
- name: "Switch to systemd_resolved"
hosts: "{{ systemd_resolved_hosts | default('systemd_resolved') }}"
become: true
roles:
- role: "systemd_resolved"

View file

@ -0,0 +1,4 @@
---
systemd_resolved_dns_servers:
- "1.1.1.1"
- "9.9.9.9"

View file

@ -0,0 +1,6 @@
---
- name: "Restart resolved"
ansible.builtin.systemd:
name: "systemd-resolved"
state: "restarted"
listen: "restart resolved"

View file

@ -0,0 +1,34 @@
---
- name: "Install resolved"
ansible.builtin.package:
name: "systemd-resolved"
- name: "Configure DNS server"
ansible.builtin.lineinfile:
path: "/etc/systemd/resolved.conf"
regexp: "^#?DNS="
insertafter: "[Resolve]"
line: "DNS={{ systemd_resolved_dns_servers | join(' ') }}"
notify: "restart resolved"
- name: "Enable DNSSEC"
ansible.builtin.lineinfile:
path: "/etc/systemd/resolved.conf"
regexp: "^#?DNSSEC="
insertafter: "[Resolve]"
line: "DNSSEC=yes"
notify: "restart resolved"
- name: "Enable resolved"
ansible.builtin.systemd:
name: "systemd-resolved"
masked: false
enabled: true
state: "started"
- name: "Use resolved"
ansible.builtin.file:
src: "/run/systemd/resolve/stub-resolv.conf"
dest: "/etc/resolv.conf"
state: "link"
force: true