From c017090d8b4869591746f75b0aa000a3e1a5bb07 Mon Sep 17 00:00:00 2001 From: Bartek Grzybowski Date: Tue, 13 Jul 2021 13:02:07 +0200 Subject: [CODESEARCH] Rework the nameserver provisioning Default OS resolver is set using native systemd-resolved facilities in a way that it will be persisted after box reload. Default nameserver is set within Vagrantfile and can be altered if needed. Vagrant-libvirt specific resolver settings were removed in favor of a general one. As of now it should be possible to also run this box using Virtualbox provider. Change-Id: Icdd1eb8bf3677c4616b1ac7d6b3387e0f4c7535a Issue-ID: INT-1940 Signed-off-by: Bartek Grzybowski --- bootstrap/codesearch/Vagrantfile | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'bootstrap/codesearch/Vagrantfile') diff --git a/bootstrap/codesearch/Vagrantfile b/bootstrap/codesearch/Vagrantfile index 4c77309c9..3df687a96 100644 --- a/bootstrap/codesearch/Vagrantfile +++ b/bootstrap/codesearch/Vagrantfile @@ -1,23 +1,25 @@ # -*- mode: ruby -*- # -*- coding: utf-8 -*- -host_ip = "192.168.121.1" +nameserver = "8.8.8.8" synced_folder = "/vagrant" houndd_bin = "${HOME}/go/bin/houndd" houndd_config = "${HOME}/config.json" onap_git = "git.onap.org" $replace_dns = <<-SCRIPT - HOST_IP="$1" - rm -f /etc/resolv.conf # drop its dynamic management by systemd-resolved - echo nameserver "$HOST_IP" | tee /etc/resolv.conf + ns="$1" + # persist resolver settings + sed -i "s/addresses:.*/addresses: [${ns}]/" /etc/netplan/01-netcfg.yaml + # setup resolver for current boot session + resolvectl dns eth0 ${ns} SCRIPT Vagrant.configure("2") do |config| config.vm.box = "generic/ubuntu2004" config.vm.synced_folder ".", synced_folder, type: "rsync", rsync__exclude: "Vagrantfile" config.vm.network "forwarded_port", guest: 6080, host: 6080 - config.vm.provision "replace_dns", type: :shell, run: "always", inline: $replace_dns, args: host_ip + config.vm.provision "replace_dns", type: :shell, inline: $replace_dns, args: nameserver config.vm.provision "dependencies", type: :shell, inline: <<-SHELL export DEBIAN_FRONTEND=noninteractive apt-get update -- cgit 1.2.3-korg