-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
57 lines (48 loc) · 1.7 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
DISCOVER_NODES ||= 0
PROVISION_MAAS ||= TRUE
SSH_TUNNEL ||= FALSE
vagrant_dir = File.expand_path(File.dirname(__FILE__))
if File.exists?(File.join(vagrant_dir, 'Vagrantfile.custom'))
eval(IO.read(File.join(vagrant_dir, 'Vagrantfile.custom')), binding)
end
Vagrant.configure("2") do |config|
config.vm.define :maas do |maas|
maas.vm.box = "generic/ubuntu1804"
maas.vm.hostname = "maas-region"
maas.vm.provider :libvirt do |domain|
domain.driver = "qemu"
domain.memory = 2048
domain.cpus = 2
domain.nested = true
end
maas.vm.network "private_network", libvirt__network_name: "pxe", libvirt__dhcp_enabled: false, ip: "192.168.61.8"
if SSH_TUNNEL
maas.vm.network :forwarded_port, guest: 5240, host: 80, host_ip: "0.0.0.0"
end
$script = <<-'SCRIPT'
sudo add-apt-repository ppa:maas/2.8 && apt install maas -y
maas createadmin --username admin --password admin --email [email protected]
maas apikey --username admin > api_key
cat api_key
SCRIPT
if PROVISION_MAAS
maas.vm.provision "shell", inline: $script
end
end
if DISCOVER_NODES > 0
(1..self.class.const_get("DISCOVER_NODES")).each do |i|
config.vm.define "discover-#{i}" do |discover|
discover.vm.provider :libvirt do |domain|
domain.memory = 2048
domain.cpus = 2
domain.nested = true
domain.mgmt_attach = false
boot_network = {'network' => 'pxe'}
domain.storage :file, :size => '20G', :type => 'qcow2'
domain.boot boot_network
end
discover.vm.network "private_network", libvirt__network_name: "pxe", libvirt__dhcp_enabled: false
end
end
end
end