4 # IMPORTANT To bring up the machines, use the "--no-parallel" option
5 # to vagrant up. This is to workaround dependencies between the jump
6 # machine and the machine pool machines. Specifically, the pool
7 # machines will fail to come up until the baremetal network (created
8 # by vagrant from the jump machine definition) is up.
12 :baremetal_cidr => '192.168.151.0/24',
16 $post_up_message = <<MSG
17 ------------------------------------------------------
19 To get started with ICN:
22 vagrant@jump:~$ sudo su
23 root@jump:/home/vagrant# cd /icn
24 root@jump:/home/vagrant# make install
26 ------------------------------------------------------
32 # The ICN baremetal network will be the vagrant management network.
33 # It is created automatically by vagrant. The provisioning network
34 # will be a vagrant private network, and is required to be created by
35 # this script. The IPMI network is created with virtualbmc.
40 Vagrant.configure("2") do |config|
42 config.vm.define 'jump' do |m|
43 # Note the apparent typo in the name below, it is correct as-is
44 m.vm.box = 'intergratedcloudnative/ubuntu1804'
45 m.vm.hostname = 'jump'
46 m.vm.synced_folder '.', '/icn'
47 m.vm.provider :libvirt do |libvirt|
48 libvirt.graphics_ip = '0.0.0.0'
49 libvirt.default_prefix = "#{vars[:site]}-"
50 libvirt.cpu_mode = 'host-passthrough'
52 libvirt.memory = 16384
55 # The ICN baremetal network is the vagrant management network,
56 # and is created by vagrant for us
57 libvirt.management_network_name = "#{vars[:site]}-baremetal"
58 libvirt.management_network_address = vars[:baremetal_cidr]
59 libvirt.management_network_autostart = true
62 # The ICN provisioning network will be a vagrant private network
63 # created upon bringing up the jump machine
64 m.trigger.before [:up] do |trigger|
65 trigger.name = 'Creating provisioning network'
66 trigger.run = {inline: "./tools/vagrant/create_provisioning_network.sh #{vars[:site]}"}
68 m.trigger.after [:destroy] do |trigger|
69 trigger.name = 'Destroying provisioning network'
70 trigger.run = {inline: "./tools/vagrant/destroy_provisioning_network.sh #{vars[:site]}"}
72 m.vm.network :private_network,
73 :libvirt__network_name => "#{vars[:site]}-provisioning",
76 # IPMI control of machines is provided by vbmc on the host
77 m.trigger.after [:up] do |trigger|
78 trigger.name = 'Starting virtualbmc for IPMI network'
79 trigger.run = {inline: "./tools/vagrant/start_vbmc.sh"}
81 m.trigger.after [:destroy] do |trigger|
82 trigger.name = 'Stopping virtualbmc for IPMI network'
83 trigger.run = {inline: "./tools/vagrant/stop_vbmc.sh"}
86 m.trigger.after [:up] do |trigger|
87 trigger.name = 'Creating ICN user_config.sh'
88 trigger.run = {inline: "./tools/vagrant/create_user_config.sh"}
90 m.vm.provision 'Configuring ICN prerequisites', type: 'shell', privileged: true, inline: <<-SHELL
91 ssh-keygen -f "${HOME}/.ssh/id_rsa" -P "" <<<y
92 DEBIAN_FRONTEND=noninteractive apt-get install -y make
94 m.vm.post_up_message = $post_up_message
97 # The machine pool used by cluster creation
98 (1..vars[:num_machines]).each do |i|
99 config.vm.define "machine-#{i}" do |m|
100 m.vm.hostname = "machine-#{i}"
101 m.vm.provider :libvirt do |libvirt|
102 libvirt.graphics_ip = '0.0.0.0'
103 libvirt.default_prefix = "#{vars[:site]}-"
104 libvirt.cpu_mode = 'host-passthrough'
106 libvirt.memory = 16384
107 libvirt.nested = true
108 # The image will be provisioned by ICN so just create an empty
109 # disk for the machine
110 libvirt.storage :file, :size => 50, :type => 'raw', :cache => 'none'
111 # Management attach is false so that vagrant will not interfere
112 # with these machines: the jump server will manage them
114 libvirt.mgmt_attach = false
116 # The provisioning network must be listed first for PXE boot to
117 # the metal3/ironic provided image
118 m.vm.network :private_network,
119 :libvirt__network_name => "#{vars[:site]}-provisioning",
121 m.vm.network :private_network,
122 :libvirt__network_name => "#{vars[:site]}-baremetal",
126 m.trigger.after [:up] do |trigger|
127 trigger.name = 'Adding machine to IPMI network'
128 trigger.run = {inline: "./tools/vagrant/add_machine_to_vbmc.sh #{i} #{vars[:site]} machine-#{i}"}
130 m.trigger.after [:destroy] do |trigger|
131 trigger.name = 'Removing machine from IPMI network'
132 trigger.run = {inline: "./tools/vagrant/remove_machine_from_vbmc.sh #{i} #{vars[:site]} machine-#{i}"}
135 # Create configuration for ICN provisioning
136 m.trigger.after [:up] do |trigger|
137 if i == vars[:num_machines] then
138 trigger.info = 'Creating nodes.json.sample describing the machines'
139 trigger.run = {inline: "./tools/vagrant/create_nodes_json_sample.sh #{vars[:num_machines]} #{vars[:site]} machine-"}
142 m.trigger.after [:up] do |trigger|
143 if i == vars[:num_machines] then
144 trigger.info = 'Creating Provisioning resource describing the cluster'
145 trigger.run = {inline: "./tools/vagrant/create_provisioning_cr.sh #{vars[:num_machines]} #{vars[:site]} machine-"}