Skip to content

Commit

Permalink
Development VMs: override DNS configuration
Browse files Browse the repository at this point in the history
Override default DNS configuration of development VMs (including
the controller), because it does not work reliably on Windows-based
VMs. Use the Google DNS servers instead.
  • Loading branch information
stsnel committed Mar 28, 2024
1 parent 077ae21 commit bb12c4f
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 0 deletions.
1 change: 1 addition & 0 deletions environments/development/host_vars/epos-msl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
ansible_host: 192.168.60.10 # EPOS-MSL host
ansible_user: vagrant # Administrative user on instance for Ansible
ansible_ssh_private_key_file: vagrant/ssh/vagrant # Path to private key file of administrative user
commons_use_google_dns: true

#########################
# EPOS-MSL configuration
Expand Down
4 changes: 4 additions & 0 deletions roles/common/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
# copyright Utrecht University

commons_use_google_dns: false
24 changes: 24 additions & 0 deletions roles/common/files/resolved.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See resolved.conf(5) for details

[Resolve]
DNS=8.8.8.8
FallbackDNS=8.8.4.4
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#DNSOverTLS=no
#Cache=no-negative
#DNSStubListener=yes
#ReadEtcHosts=yes
6 changes: 6 additions & 0 deletions roles/common/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@
ansible.builtin.service:
name: firewalld
state: restarted


- name: Restart systemd-resolved
ansible.builtin.service:
name: systemd-resolved
state: restarted
15 changes: 15 additions & 0 deletions roles/common/tasks/google_dns.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
# copyright Utrecht University

- name: Update systemd-resolved config to use Google DNS servers
ansible.builtin.copy:
src: files/resolved.conf
dest: /etc/systemd/resolved.conf
owner: root
group: root
mode: "0644"
notify: Restart systemd-resolved


- name: Flush handlers for immediate effect of changing DNS configuration
ansible.builtin.meta: flush_handlers
3 changes: 3 additions & 0 deletions roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
# copyright Utrecht University

- name: Update local DNS settings
ansible.builtin.import_tasks: google_dns.yml
when: commons_use_google_dns
- name: Run apt update
ansible.builtin.import_tasks: apt_update.yml
- name: Configure firewall
Expand Down
33 changes: 33 additions & 0 deletions vagrant/provision_controller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,39 @@
set -e
set -x

# Configure VM to use Google DNS servers - the default configuration
# does not work reliably on Windows.

cat << RESOLVEDCONF > resolved.conf
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See resolved.conf(5) for details
[Resolve]
DNS=8.8.8.8
FallbackDNS=8.8.4.4
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#DNSOverTLS=no
#Cache=no-negative
#DNSStubListener=yes
#ReadEtcHosts=yes
RESOLVEDCONF

sudo cp resolved.conf /etc/systemd
sudo systemctl restart systemd-resolved

sudo apt update

# Install Git if not present.
Expand Down

0 comments on commit bb12c4f

Please sign in to comment.