35 lines
No EOL
877 B
YAML
35 lines
No EOL
877 B
YAML
---
|
|
- name: Fix DNS on K3s Nodes
|
|
hosts: k3s_cluster
|
|
become: true
|
|
|
|
tasks:
|
|
- name: Update resolv.conf to use Quad9 DNS
|
|
copy:
|
|
content: |
|
|
nameserver 9.9.9.9
|
|
nameserver 149.112.112.112
|
|
dest: /etc/resolv.conf
|
|
backup: yes
|
|
|
|
- name: Ensure systemd-resolved is not managing resolv.conf
|
|
systemd:
|
|
name: systemd-resolved
|
|
state: stopped
|
|
enabled: no
|
|
ignore_errors: yes
|
|
|
|
- name: Test DNS resolution
|
|
command: nslookup registry-1.docker.io
|
|
register: dns_test
|
|
changed_when: false
|
|
|
|
- name: Show DNS test results
|
|
debug:
|
|
msg: "{{ dns_test.stdout_lines }}"
|
|
|
|
- name: Restart containerd to pick up DNS changes
|
|
systemd:
|
|
name: containerd
|
|
state: restarted
|
|
when: inventory_hostname in groups['k3s_cluster'] |