X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=Vagrantfile;h=f3c700e6593903c3865ab7b53ae9ac91e98c22b1;hb=e3be88235a3456ea1b7fd34460d21d894ba21871;hp=25d0ad40b52137cc84996f2baf657cdc69ac5f1e;hpb=de3d22a9939db1f5d9042743100b65a5f15fa671;p=icn.git diff --git a/Vagrantfile b/Vagrantfile index 25d0ad4..f3c700e 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,16 +1,150 @@ # -*- mode: ruby -*- # vi: set ft=ruby : +# IMPORTANT To bring up the machines, use the "--no-parallel" option +# to vagrant up. This is to workaround dependencies between the jump +# machine and the machine pool machines. Specifically, the pool +# machines will fail to come up until the baremetal network (created +# by vagrant from the jump machine definition) is up. + +vars = { + :site => 'vm', + :baremetal_cidr => '192.168.151.0/24', + :num_machines => 2 +} + +$post_up_message = < "#{vars[:site]}-provisioning", + :type => 'dhcp' + + # IPMI control of machines is provided by vbmc on the host + m.trigger.after [:up] do |trigger| + trigger.name = 'Starting virtualbmc for IPMI network' + trigger.run = {inline: "./tools/vagrant/start_vbmc.sh"} + end + m.trigger.after [:destroy] do |trigger| + trigger.name = 'Stopping virtualbmc for IPMI network' + trigger.run = {inline: "./tools/vagrant/stop_vbmc.sh"} + end + + m.trigger.after [:up] do |trigger| + trigger.name = 'Creating ICN user_config.sh' + trigger.run = {inline: "./tools/vagrant/create_user_config.sh"} + end + m.vm.provision 'Configuring ICN prerequisites', type: 'shell', privileged: true, inline: <<-SHELL + ssh-keygen -f "${HOME}/.ssh/id_rsa" -P "" << 50, :type => 'raw', :cache => 'none' + # Management attach is false so that vagrant will not interfere + # with these machines: the jump server will manage them + # completely + libvirt.mgmt_attach = false + end + # The provisioning network must be listed first for PXE boot to + # the metal3/ironic provided image + m.vm.network :private_network, + :libvirt__network_name => "#{vars[:site]}-provisioning", + :type => 'dhcp' + m.vm.network :private_network, + :libvirt__network_name => "#{vars[:site]}-baremetal", + :type => 'dhcp' + + # IPMI control + m.trigger.after [:up] do |trigger| + trigger.name = 'Adding machine to IPMI network' + trigger.run = {inline: "./tools/vagrant/add_machine_to_vbmc.sh #{i} #{vars[:site]} machine-#{i}"} + end + m.trigger.after [:destroy] do |trigger| + trigger.name = 'Removing machine from IPMI network' + trigger.run = {inline: "./tools/vagrant/remove_machine_from_vbmc.sh #{i} #{vars[:site]} machine-#{i}"} + end + + # Create configuration for ICN provisioning + m.trigger.after [:up] do |trigger| + if i == vars[:num_machines] then + trigger.info = 'Creating nodes.json.sample describing the machines' + trigger.run = {inline: "./tools/vagrant/create_nodes_json_sample.sh #{vars[:num_machines]} #{vars[:site]} machine-"} + end + end + m.trigger.after [:up] do |trigger| + if i == vars[:num_machines] then + trigger.info = 'Creating Provisioning resource describing the cluster' + trigger.run = {inline: "./tools/vagrant/create_provisioning_cr.sh #{vars[:num_machines]} #{vars[:site]} machine-"} + end + end + end end end