From ed6110546d621c8d3924aa813fba1209d47fb1be Mon Sep 17 00:00:00 2001 From: =?utf8?q?Javier=20B=C3=A9rtoli?= Date: Wed, 3 Mar 2021 08:57:03 -0300 Subject: [PATCH] fix(compute-images): make resolver setting optional MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Also, change docker's systemd service path to /etc instead of /lib refs #17438 Arvados-DCO-1.1-Signed-off-by: Javier Bértoli --- tools/compute-images/build.sh | 2 +- tools/compute-images/scripts/base.sh | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/tools/compute-images/build.sh b/tools/compute-images/build.sh index fb02ce9442..36f0e18a3d 100755 --- a/tools/compute-images/build.sh +++ b/tools/compute-images/build.sh @@ -49,7 +49,7 @@ Options: Azure SKU image to use --ssh_user (default: packer) The user packer will use to log into the image - --resolver (default: 8.8.8.8) + --resolver (default: host's network provided) The dns resolver for the machine --reposuffix (default: unset) Set this to "-dev" to track the unstable/dev Arvados repositories diff --git a/tools/compute-images/scripts/base.sh b/tools/compute-images/scripts/base.sh index eeda573884..be67ffb567 100644 --- a/tools/compute-images/scripts/base.sh +++ b/tools/compute-images/scripts/base.sh @@ -78,8 +78,12 @@ $SUDO echo -e "{\n \"Quota\": \"10G\",\n \"RemoveStoppedContainers\": \"always $SUDO sed -i 's/GRUB_CMDLINE_LINUX=""/GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"/g' /etc/default/grub $SUDO update-grub -# Set a higher ulimit for docker -$SUDO sed -i "s/ExecStart=\(.*\)/ExecStart=\1 --default-ulimit nofile=10000:10000 --dns ${RESOLVER}/g" /lib/systemd/system/docker.service +# Set a higher ulimit and the resolver (if set) for docker +if [ "x$RESOLVER" != "x" ]; then + SET_RESOLVER="--dns ${RESOLVER}" +fi + +$SUDO sed "s/ExecStart=\(.*\)/ExecStart=\1 --default-ulimit nofile=10000:10000 ${SET_RESOLVER}/g" > /etc/systemd/system/docker.service $SUDO systemctl daemon-reload # Make sure user_allow_other is set in fuse.conf @@ -97,10 +101,11 @@ $SUDO chown -R crunch:crunch /home/crunch/.ssh $SUDO chmod 600 /home/crunch/.ssh/authorized_keys $SUDO chmod 700 /home/crunch/.ssh/ -# Make sure we resolve via the provided resolver IP. Prepending is good enough because +# Make sure we resolve via the provided resolver IP if set. Prepending is good enough because # unless 'rotate' is set, the nameservers are queried in order (cf. man resolv.conf) -$SUDO sed -i "s/#prepend domain-name-servers 127.0.0.1;/prepend domain-name-servers ${RESOLVER};/" /etc/dhcp/dhclient.conf - +if [ "x$RESOLVER" != "x" ]; then + $SUDO sed -i "s/#prepend domain-name-servers 127.0.0.1;/prepend domain-name-servers ${RESOLVER};/" /etc/dhcp/dhclient.conf +fi # Set up the cloud-init script that will ensure encrypted disks $SUDO mv /tmp/usr-local-bin-ensure-encrypted-partitions.sh /usr/local/bin/ensure-encrypted-partitions.sh $SUDO chmod 755 /usr/local/bin/ensure-encrypted-partitions.sh -- 2.30.2