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.box_version = '1.0.0'
46 m.vm.hostname = 'jump'
47 m.vm.synced_folder '.', '/icn'
48 m.vm.provider :libvirt do |libvirt|
49 libvirt.graphics_ip = '0.0.0.0'
50 libvirt.default_prefix = "#{vars[:site]}-"
51 libvirt.cpu_mode = 'host-passthrough'
53 libvirt.memory = 24576
56 # The ICN baremetal network is the vagrant management network,
57 # and is created by vagrant for us
58 libvirt.management_network_name = "#{vars[:site]}-baremetal"
59 libvirt.management_network_address = vars[:baremetal_cidr]
60 libvirt.management_network_autostart = true
63 # The ICN provisioning network will be a vagrant private network
64 # created upon bringing up the jump machine
65 m.trigger.before [:up] do |trigger|
66 trigger.name = 'Creating provisioning network'
67 trigger.run = {inline: "./tools/vagrant/create_provisioning_network.sh #{vars[:site]}"}
69 m.trigger.after [:destroy] do |trigger|
70 trigger.name = 'Destroying provisioning network'
71 trigger.run = {inline: "./tools/vagrant/destroy_provisioning_network.sh #{vars[:site]}"}
73 m.vm.network :private_network,
74 :libvirt__network_name => "#{vars[:site]}-provisioning",
77 # IPMI control of machines is provided by vbmc on the host
78 m.trigger.after [:up] do |trigger|
79 trigger.name = 'Starting virtualbmc for IPMI network'
80 trigger.run = {inline: "./tools/vagrant/start_vbmc.sh"}
82 m.trigger.after [:destroy] do |trigger|
83 trigger.name = 'Stopping virtualbmc for IPMI network'
84 trigger.run = {inline: "./tools/vagrant/stop_vbmc.sh"}
87 m.trigger.after [:up] do |trigger|
88 trigger.name = 'Creating ICN user_config.sh'
89 trigger.run = {inline: "./tools/vagrant/create_user_config.sh"}
91 m.vm.provision 'Configuring ICN prerequisites', type: 'shell', privileged: true, inline: <<-SHELL
92 ssh-keygen -f "${HOME}/.ssh/id_rsa" -P "" <<<y
93 DEBIAN_FRONTEND=noninteractive apt-get install -y make
95 m.vm.post_up_message = $post_up_message
98 # The machine pool used by cluster creation
99 (1..vars[:num_machines]).each do |i|
100 config.vm.define "machine-#{i}" do |m|
101 m.vm.hostname = "machine-#{i}"
102 m.vm.provider :libvirt do |libvirt|
103 libvirt.graphics_ip = '0.0.0.0'
104 libvirt.default_prefix = "#{vars[:site]}-"
105 libvirt.cpu_mode = 'host-passthrough'
107 libvirt.memory = 16384
108 libvirt.nested = true
109 # The image will be provisioned by ICN so just create an empty
110 # disk for the machine
111 libvirt.storage :file, :size => 50, :type => 'raw', :cache => 'none'
112 # Management attach is false so that vagrant will not interfere
113 # with these machines: the jump server will manage them
115 libvirt.mgmt_attach = false
117 # The provisioning network must be listed first for PXE boot to
118 # the metal3/ironic provided image
119 m.vm.network :private_network,
120 :libvirt__network_name => "#{vars[:site]}-provisioning",
122 m.vm.network :private_network,
123 :libvirt__network_name => "#{vars[:site]}-baremetal",
127 m.trigger.after [:up] do |trigger|
128 trigger.name = 'Adding machine to IPMI network'
129 trigger.run = {inline: "./tools/vagrant/add_machine_to_vbmc.sh #{i} #{vars[:site]} machine-#{i}"}
131 m.trigger.after [:destroy] do |trigger|
132 trigger.name = 'Removing machine from IPMI network'
133 trigger.run = {inline: "./tools/vagrant/remove_machine_from_vbmc.sh #{i} #{vars[:site]} machine-#{i}"}
136 # Create configuration for ICN provisioning
137 m.trigger.after [:up] do |trigger|
138 if i == vars[:num_machines] then
139 trigger.info = 'Creating nodes.json.sample describing the machines'
140 trigger.run = {inline: "./tools/vagrant/create_nodes_json_sample.sh #{vars[:num_machines]} #{vars[:site]} machine-"}
143 m.trigger.after [:up] do |trigger|
144 if i == vars[:num_machines] then
145 trigger.info = 'Creating Provisioning resource describing the cluster'
146 trigger.run = {inline: "./tools/vagrant/create_provisioning_cr.sh #{vars[:num_machines]} #{vars[:site]} machine-"}