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:/icn# make jump_server
25 root@jump:/icn# make cluster
27 ------------------------------------------------------
33 # The ICN baremetal network will be the vagrant management network.
34 # It is created automatically by vagrant. The provisioning network
35 # will be a vagrant private network, and is required to be created by
36 # this script. The IPMI network is created with virtualbmc.
41 Vagrant.configure("2") do |config|
43 config.vm.define 'jump' do |m|
44 # Note the apparent typo in the name below, it is correct as-is
45 m.vm.box = 'intergratedcloudnative/ubuntu1804'
46 m.vm.box_version = '1.0.0'
47 m.vm.hostname = 'jump'
48 m.vm.synced_folder '.', '/icn'
49 m.vm.provider :libvirt do |libvirt|
50 libvirt.graphics_ip = '0.0.0.0'
51 libvirt.default_prefix = "#{vars[:site]}-"
52 libvirt.cpu_mode = 'host-passthrough'
54 libvirt.memory = 24576
57 # The ICN baremetal network is the vagrant management network,
58 # and is created by vagrant for us
59 libvirt.management_network_name = "#{vars[:site]}-baremetal"
60 libvirt.management_network_address = vars[:baremetal_cidr]
61 libvirt.management_network_autostart = true
64 # The ICN provisioning network will be a vagrant private network
65 # created upon bringing up the jump machine
66 m.trigger.before [:up] do |trigger|
67 trigger.name = 'Creating provisioning network'
68 trigger.run = {inline: "./tools/vagrant/create_provisioning_network.sh #{vars[:site]}"}
70 m.trigger.after [:destroy] do |trigger|
71 trigger.name = 'Destroying provisioning network'
72 trigger.run = {inline: "./tools/vagrant/destroy_provisioning_network.sh #{vars[:site]}"}
74 m.vm.network :private_network,
75 :libvirt__network_name => "#{vars[:site]}-provisioning",
78 # IPMI control of machines is provided by vbmc on the host
79 m.trigger.after [:up] do |trigger|
80 trigger.name = 'Starting virtualbmc for IPMI network'
81 trigger.run = {inline: "./tools/vagrant/start_vbmc.sh"}
83 m.trigger.after [:destroy] do |trigger|
84 trigger.name = 'Stopping virtualbmc for IPMI network'
85 trigger.run = {inline: "./tools/vagrant/stop_vbmc.sh"}
88 m.trigger.after [:up] do |trigger|
89 trigger.name = 'Creating ICN user_config.sh'
90 trigger.run = {inline: "./tools/vagrant/create_user_config.sh"}
92 m.vm.provision 'Configuring ICN prerequisites', type: 'shell', privileged: true, inline: <<-SHELL
93 ssh-keygen -f "${HOME}/.ssh/id_rsa" -P "" <<<y
94 DEBIAN_FRONTEND=noninteractive apt-get install -y make
96 m.vm.post_up_message = $post_up_message
99 # The machine pool used by cluster creation
100 (1..vars[:num_machines]).each do |i|
101 config.vm.define "machine-#{i}" do |m|
102 m.vm.hostname = "machine-#{i}"
103 m.vm.provider :libvirt do |libvirt|
104 libvirt.graphics_ip = '0.0.0.0'
105 libvirt.default_prefix = "#{vars[:site]}-"
106 libvirt.cpu_mode = 'host-passthrough'
108 libvirt.memory = 16384
109 libvirt.nested = true
110 # The image will be provisioned by ICN so just create an empty
111 # disk for the machine
112 libvirt.storage :file, :size => 50, :type => 'raw', :cache => 'none'
113 # Management attach is false so that vagrant will not interfere
114 # with these machines: the jump server will manage them
116 libvirt.mgmt_attach = false
118 # The provisioning network must be listed first for PXE boot to
119 # the metal3/ironic provided image
120 m.vm.network :private_network,
121 :libvirt__network_name => "#{vars[:site]}-provisioning",
123 m.vm.network :private_network,
124 :libvirt__network_name => "#{vars[:site]}-baremetal",
128 m.trigger.after [:up] do |trigger|
129 trigger.name = 'Adding machine to IPMI network'
130 trigger.run = {inline: "./tools/vagrant/add_machine_to_vbmc.sh #{i} #{vars[:site]} machine-#{i}"}
132 m.trigger.after [:destroy] do |trigger|
133 trigger.name = 'Removing machine from IPMI network'
134 trigger.run = {inline: "./tools/vagrant/remove_machine_from_vbmc.sh #{i} #{vars[:site]} machine-#{i}"}
137 # Create configuration for ICN provisioning
138 m.trigger.after [:up] do |trigger|
139 if i == vars[:num_machines] then
140 trigger.info = 'Creating nodes.json.sample describing the machines'
141 trigger.run = {inline: "./tools/vagrant/create_nodes_json_sample.sh #{vars[:num_machines]} #{vars[:site]} machine-"}
144 m.trigger.after [:up] do |trigger|
145 if i == vars[:num_machines] then
146 trigger.info = 'Creating Provisioning resource describing the cluster'
147 trigger.run = {inline: "./tools/vagrant/create_provisioning_cr.sh #{vars[:num_machines]} #{vars[:site]} machine-"}