mirror of
https://github.com/famedly/ansible-collection-base
synced 2024-11-13 23:57:09 +00:00
feat(resolved): add role
This commit is contained in:
parent
66ef48220e
commit
261aefc9af
4 changed files with 50 additions and 0 deletions
6
playbooks/systemd_resolved.yml
Normal file
6
playbooks/systemd_resolved.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
- name: "Switch to systemd_resolved"
|
||||
hosts: "{{ systemd_resolved_hosts | default('systemd_resolved') }}"
|
||||
become: true
|
||||
roles:
|
||||
- role: "systemd_resolved"
|
4
roles/systemd_resolved/defaults/main.yml
Normal file
4
roles/systemd_resolved/defaults/main.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
systemd_resolved_dns_servers:
|
||||
- "1.1.1.1"
|
||||
- "9.9.9.9"
|
6
roles/systemd_resolved/handlers/main.yml
Normal file
6
roles/systemd_resolved/handlers/main.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
- name: "Restart resolved"
|
||||
ansible.builtin.systemd:
|
||||
name: "systemd-resolved"
|
||||
state: "restarted"
|
||||
listen: "restart resolved"
|
34
roles/systemd_resolved/tasks/main.yml
Normal file
34
roles/systemd_resolved/tasks/main.yml
Normal 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
|
Loading…
Reference in a new issue