add cmk in KuD
[multicloud/k8s.git] / kud / hosting_providers / vagrant / Vagrantfile
index 58251fe..bcaa9d0 100644 (file)
@@ -10,8 +10,8 @@
 ##############################################################################
 
 box = {
-  :virtualbox => { :name => 'elastic/ubuntu-18.04-x86_64', :version => '20191013.0.0' },
-  :libvirt => { :name => 'peru/ubuntu-18.04-server-amd64'}
+  :virtualbox => { :name => 'elastic/ubuntu-18.04-x86_64', :version => '20191013.0.0'},
+  :libvirt => { :name => 'intergratedcloudnative/ubuntu1804', :version => '1.0.0'}
 }
 
 require 'yaml'
@@ -27,7 +27,7 @@ File.open(File.dirname(__FILE__) + "/inventory/hosts.ini", "w") do |inventory_fi
   nodes.each do |node|
     inventory_file.puts("#{node['name']}\tansible_ssh_host=#{node['ip']} ansible_ssh_port=22")
   end
-  ['kube-master', 'kube-node', 'etcd', 'ovn-central', 'ovn-controller', 'virtlet'].each do|group|
+  ['kube-master', 'kube-node', 'etcd', 'ovn-central', 'ovn-controller', 'virtlet', 'cmk'].each do|group|
     inventory_file.puts("\n[#{group}]")
     nodes.each do |node|
       if node['roles'].include?("#{group}")
@@ -76,8 +76,24 @@ Vagrant.configure("2") do |config|
     v.random_hostname = true
   end
 
+  sync_type = "virtualbox"
+  if provider == :libvirt
+    sync_type = "nfs"
+  end
+
   nodes.each do |node|
     config.vm.define node['name'] do |nodeconfig|
+      if node['roles'].include?("kube-master")
+        nodeconfig.vm.synced_folder '../../../', '/home/vagrant/multicloud-k8s/', type: sync_type
+      end
+      if node['roles'].include?("kube-node")
+        nodeconfig.vm.provision 'shell', privileged: false do |sh|
+          sh.inline = <<-SHELL
+            sudo sed -i 's:GRUB_CMDLINE_LINUX=.*:GRUB_CMDLINE_LINUX="isolcpus=0-7":' /etc/default/grub
+            sudo update-grub
+          SHELL
+        end
+      end
       nodeconfig.vm.hostname = node['name']
       nodeconfig.vm.network :private_network, :ip => node['ip'], :type => :static
       nodeconfig.vm.provider 'virtualbox' do |v|
@@ -111,10 +127,7 @@ Vagrant.configure("2") do |config|
       end
     end
   end
-  sync_type = "virtualbox"
-  if provider == :libvirt
-    sync_type = "nfs"
-  end
+
   config.vm.define :installer, primary: true, autostart: false do |installer|
     installer.vm.hostname = "multicloud"
     installer.vm.network :private_network, :ip => "10.10.10.2", :type => :static
@@ -122,10 +135,11 @@ Vagrant.configure("2") do |config|
     installer.vm.provision 'shell', privileged: false do |sh|
       sh.env = {'KUD_PLUGIN_ENABLED': 'false', 'OVN_CENTRAL_INTERFACE': 'eth1'}
       sh.inline = <<-SHELL
-        cp /vagrant/insecure_keys/key.pub /home/vagrant/.ssh/id_rsa.pub
-        cp /vagrant/insecure_keys/key /home/vagrant/.ssh/id_rsa
+        cp /home/vagrant/multicloud-k8s/kud/hosting_providers/vagrant/insecure_keys/key.pub /home/vagrant/.ssh/id_rsa.pub
+        cp /home/vagrant/multicloud-k8s/kud/hosting_providers/vagrant/insecure_keys/key /home/vagrant/.ssh/id_rsa
         chown vagrant /home/vagrant/.ssh/id_rsa
         chmod 400 /home/vagrant/.ssh/id_rsa
+        sudo apt install jq -y
         cd /home/vagrant/multicloud-k8s/kud/hosting_providers/vagrant/ && ./installer.sh | tee kud_installer.log
       SHELL
     end