Skip to content

Commit

Permalink
Custom DNS: add support for EL9
Browse files Browse the repository at this point in the history
  • Loading branch information
FuHsinyu authored Mar 4, 2025
1 parent 5b75f2f commit 532120a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
30 changes: 29 additions & 1 deletion roles/common/tasks/custom_dns.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,43 @@
---
# copyright Utrecht University

- name: Update systemd-resolved config to use Google DNS servers
- name: Update systemd-resolved config to use Google DNS servers (Ubuntu)
ansible.builtin.template:
src: resolved.conf.j2
dest: /etc/systemd/resolved.conf
owner: root
group: root
mode: "0644"
notify: Restart systemd-resolved
when: ansible_os_family == 'Debian'


- name: Update resolv.conf to use Google DNS servers (EL9)
become: true
when: ansible_os_family == 'RedHat'
block:
- name: Create manually configured DNS settings file
ansible.builtin.copy:
dest: /etc/resolv.conf.manually-configured
content: |
search yoda.test
nameserver {{ common_custom_dns_primary }}
nameserver {{ common_custom_dns_secondary }}
owner: root
group: root
mode: '0644'

- name: Remove existing /etc/resolv.conf
ansible.builtin.file:
path: /etc/resolv.conf
state: absent

- name: Create symlink for /etc/resolv.conf
ansible.builtin.file:
src: /etc/resolv.conf.manually-configured
dest: /etc/resolv.conf
state: link
force: true

- name: Flush handlers for immediate effect of changing DNS configuration
ansible.builtin.meta: flush_handlers
2 changes: 1 addition & 1 deletion roles/common/tasks/main-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

- name: Update local DNS settings
ansible.builtin.import_tasks: custom_dns.yml
when: common_custom_dns_enable and ansible_os_family == 'Debian'
when: common_custom_dns_enable

- name: Setup EPEL repository
ansible.builtin.import_tasks: epel.yml
Expand Down

0 comments on commit 532120a

Please sign in to comment.