From 6b1f78b2efca686e61058ea5848b1f31d3f59270 Mon Sep 17 00:00:00 2001
From: Pawel Wieczorek
Date: Fri, 26 Jul 2019 14:04:39 +0200
Subject: k8s: Unify provisioning scripts
This patch:
* removes remaining string interpolation (for future script reuse),
* makes DNS replacement provisioner always run.
This way VM definition is more concise and resilient.
Issue-ID: SECCOM-235
Change-Id: I382dae5e256b46577c4c8af3aa45ab4d64d1b2b9
Signed-off-by: Pawel Wieczorek
---
test/security/k8s/vagrant/dublin/Vagrantfile | 30 ++++++++++++++++++----------
1 file changed, 19 insertions(+), 11 deletions(-)
(limited to 'test/security/k8s/vagrant')
diff --git a/test/security/k8s/vagrant/dublin/Vagrantfile b/test/security/k8s/vagrant/dublin/Vagrantfile
index 36f433f18..9e92580fa 100644
--- a/test/security/k8s/vagrant/dublin/Vagrantfile
+++ b/test/security/k8s/vagrant/dublin/Vagrantfile
@@ -18,11 +18,27 @@ cluster = [
all = cluster.dup << operation
+$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
+SCRIPT
+
$add_to_docker_group = <<-SCRIPT
USER="$1"
usermod -aG docker "$USER"
SCRIPT
+$install_sshpass = <<-SCRIPT
+ apt-get update
+ apt-get install sshpass
+SCRIPT
+
+$generate_key = <<-SCRIPT
+ KEY_FILE="$1"
+ ssh-keygen -q -b 4096 -t rsa -f "$KEY_FILE" -N ""
+SCRIPT
+
$deploy_key = <<-SCRIPT
KEY="$1"
USER="$2"
@@ -57,10 +73,7 @@ Vagrant.configure('2') do |config|
end
config.vm.network :private_network, ip: machine[:ip]
- config.vm.provision :shell, inline: <<-SHELL
- rm -f /etc/resolv.conf # drop its dynamic management by systemd-resolved
- echo nameserver #{host_ip} | tee /etc/resolv.conf
- SHELL
+ config.vm.provision :shell, run: "always", inline: $replace_dns, args: host_ip
if machine[:name] == 'control'
config.vm.provision :shell, path: "../../tools/dublin/imported/openstack-k8s-controlnode.sh"
@@ -80,13 +93,8 @@ Vagrant.configure('2') do |config|
config.vm.provision :shell, path: "../../tools/dublin/get_rke.sh"
- config.vm.provision :shell, inline: <<-SHELL
- apt-get update
- apt-get install sshpass
- SHELL
- config.vm.provision :shell, privileged: false, inline: <<-SHELL
- ssh-keygen -q -b 4096 -t rsa -f #{operator_key} -N ""
- SHELL
+ config.vm.provision :shell, inline: $install_sshpass
+ config.vm.provision :shell, privileged: false, inline: $generate_key, args: operator_key
ips = ""
cluster.each { |node| ips << node[:ip] << " " }
--
cgit 1.2.3-korg