blob: abef9f8a1834cfd6d245a44ebe3e69bcdf14a226 [file] [log] [blame]
Pawel Wieczorekb7f08112019-07-19 19:10:07 +02001# -*- mode: ruby -*-
2# -*- coding: utf-8 -*-
3
4host_ip = "192.168.121.1"
5operator_key = "~/.ssh/onap-key"
6
7vm_memory = 2 * 1024
8vm_cpus = 1
9vm_box = "generic/ubuntu1804"
10
11operation = { name: 'operator', hostname: 'operator', ip: '172.17.0.254' }
12cluster = [
13 { name: 'control', hostname: 'control', ip: '172.17.0.100' },
14 { name: 'worker', hostname: 'worker', ip: '172.17.0.101' }
15]
16
17all = cluster.dup << operation
18
19Vagrant.configure('2') do |config|
20 all.each do |machine|
21 config.vm.define machine[:name] do |config|
22 config.vm.box = vm_box
23 config.vm.hostname = machine[:hostname]
24
25 config.vm.provider :virtualbox do |v|
26 v.name = machine[:name]
27 v.memory = vm_memory
28 v.cpus = vm_cpus
29 end
30
31 config.vm.provider :libvirt do |v|
32 v.memory = vm_memory
33 v.cpus = vm_cpus
34 end
35
36 config.vm.network :private_network, ip: machine[:ip]
37 config.vm.provision :shell, inline: <<-SHELL
38 rm -f /etc/resolv.conf # drop its dynamic management by systemd-resolved
39 echo nameserver #{host_ip} | tee /etc/resolv.conf
40 SHELL
41
42 if machine[:name] == 'control'
43 config.vm.provision :shell, path: "../../tools/dublin/imported/openstack-k8s-controlnode.sh"
Pawel Wieczorek07adef32019-07-23 15:02:00 +020044 config.vm.provision :shell, inline: "usermod -aG docker vagrant" # script above adds "ubuntu" user only
Pawel Wieczorekb7f08112019-07-19 19:10:07 +020045 end
46
47 if machine[:name] == 'worker'
48 config.vm.provision :shell, path: "../../tools/dublin/imported/openstack-k8s-workernode.sh"
Pawel Wieczorek07adef32019-07-23 15:02:00 +020049 config.vm.provision :shell, inline: "usermod -aG docker vagrant" # script above adds "ubuntu" user only
Pawel Wieczorekb7f08112019-07-19 19:10:07 +020050 end
51
52 if machine[:name] == 'operator'
53 config.vm.provision :shell, path: "../../tools/dublin/get_rke.sh"
54
55 config.vm.provision :shell, inline: <<-SHELL
56 apt-get update
57 apt-get install sshpass
58 SHELL
59 config.vm.provision :shell, privileged: false, inline: <<-SHELL
60 ssh-keygen -q -b 4096 -t rsa -f #{operator_key} -N ""
61 SHELL
62
63 ips = ""
64 cluster.each { |node| ips << node[:ip] << " " }
65 config.vm.provision :shell, privileged: false, inline: <<-SHELL
66 for ip in #{ips}; do
67 sshpass -p vagrant ssh-copy-id -o StrictHostKeyChecking=no -i #{operator_key} "$ip"
68 done
69 SHELL
70 end
71 end
72 end
73end