Skip to content

Commit

Permalink
add optional anasible task to enable custmized DNS (EL9)
Browse files Browse the repository at this point in the history
  • Loading branch information
FuHsinyu committed Feb 28, 2025
1 parent 1ead134 commit 898d02f
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: Configure /etc/resolv.conf via Ansible (EL9)

Check failure on line 15 in roles/common/tasks/custom_dns.yml

View workflow job for this annotation

GitHub Actions / build

key-order[task]

You can improve the task key order to: name, become, when, block

Check failure on line 15 in roles/common/tasks/custom_dns.yml

View workflow job for this annotation

GitHub Actions / build

key-order[task]

You can improve the task key order to: name, become, when, block
become: true

Check failure on line 16 in roles/common/tasks/custom_dns.yml

View workflow job for this annotation

GitHub Actions / build

yaml[trailing-spaces]

Trailing spaces

Check failure on line 16 in roles/common/tasks/custom_dns.yml

View workflow job for this annotation

GitHub Actions / build

yaml[trailing-spaces]

Trailing spaces
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: yes

Check failure on line 39 in roles/common/tasks/custom_dns.yml

View workflow job for this annotation

GitHub Actions / build

yaml[truthy]

Truthy value should be one of [false, true]

Check failure on line 39 in roles/common/tasks/custom_dns.yml

View workflow job for this annotation

GitHub Actions / build

yaml[truthy]

Truthy value should be one of [false, true]
when: ansible_os_family == 'RedHat'

- 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

Check failure on line 9 in roles/common/tasks/main-tasks.yml

View workflow job for this annotation

GitHub Actions / build

yaml[trailing-spaces]

Trailing spaces

Check failure on line 9 in roles/common/tasks/main-tasks.yml

View workflow job for this annotation

GitHub Actions / build

yaml[trailing-spaces]

Trailing spaces

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

0 comments on commit 898d02f

Please # to comment.