aboutsummaryrefslogtreecommitdiffstats
path: root/test/security
diff options
context:
space:
mode:
authorPawel Wieczorek <p.wieczorek2@samsung.com>2019-07-26 14:04:39 +0200
committerPawel Wieczorek <p.wieczorek2@samsung.com>2019-07-26 14:04:51 +0200
commit6b1f78b2efca686e61058ea5848b1f31d3f59270 (patch)
tree6630f025ff65b1466aa7b1deb54c2981dcc10cf3 /test/security
parent5ee92067ff6bcf970a0418b235ca3daa6247ff05 (diff)
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 <p.wieczorek2@samsung.com>
Diffstat (limited to 'test/security')
-rw-r--r--test/security/k8s/vagrant/dublin/Vagrantfile30
1 files changed, 19 insertions, 11 deletions
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] << " " }