-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
102 lines (98 loc) · 3.56 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# Define VMs with static private IP addresses, vcpu, memory and vagrant-box.
boxes = [
{
:name => "centos7lab1",
:box => "centos/7",
#:box_url => "http://mycompany.registry.com/artifactory/vagrant/centos7_libvirt.box",
:ram => 1024,
:vcpu => 1,
:ip => "192.168.11.101"
},
{
:name => "centos7lab2",
:box => "centos/7",
#:box_url => "http://mycompany.registry.com/artifactory/vagrant/centos7_libvirt.box",
:ram => 1024,
:vcpu => 1,
:ip => "192.168.11.102"
},
{
:name => "centos7lab3",
:box => "centos/7",
#:box_url => "http://mycompany.registry.com/artifactory/vagrant/centos7_libvirt.box",
:ram => 1024,
:vcpu => 1,
:ip => "192.168.11.103"
},
{
:name => "debian10",
:box => "debian/buster64",
#:box_url => "http://mycompany.registry.com/artifactory/vagrant/debian10_buster.box",
:ram => 1024,
:vcpu => 1,
:ip => "192.168.11.104"
},
{
:name => "focal-desktop",
:box => "peru/ubuntu-20.04-desktop-amd64",
#:box_url => "http://mycompany.registry.com/artifactory/vagrant/ubuntu-20.04-desktop-amd64.box",
:ram => 1024,
:vcpu => 1,
:ip => "192.168.11.105"
},
{
:name => "ubuntu2004",
:box => "generic/ubuntu2004",
#:box_url => "http://mycompany.registry.com/artifactory/vagrant/generic_ubuntu2004.box",
:ram => 1024,
:vcpu => 1,
:ip => "192.168.11.106"
}
]
# Provision each of the VMs.
boxes.each do |opts|
config.vm.define opts[:name] do |config|
# Only Enable this if you are connecting to Proxy server
# config.proxy.http = "http://usernam:[email protected]:80"
# config.proxy.https = "http://usernam:[email protected]:80"
# config.proxy.no_proxy = "localhost,127.0.0.1"
# config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true
config.ssh.insert_key = false
config.vm.box = opts[:box]
# config.vm.box_url = opts[:box_url]
config.vm.hostname = opts[:name]
config.vm.provider "libvirt" do |v| # or config.vm.provider :virtualbox do |v|
v.storage :file, :size => '5G'
v.storage :file, :size => '5G'
v.storage :file, :size => '5G'
v.memory = opts[:ram]
v.cpus = opts[:vcpu]
end
#Synced Directories
config.vm.synced_folder '.', '/vagrant', type: 'rsync', disabled: true
config.vm.synced_folder '.', '/vagrant', disabled: true
config.vm.synced_folder './scripts', '/vagrant/provision/scripts', type: 'rsync'
config.vm.synced_folder './files', '/vagrant/provision/files', type: 'rsync'
if opts[:box] == 'debian/buster64' # Debian 10 buster
config.nfs.functional = false
config.nfs.verify_installed = false
#config.vm.provision 'shell', path: "./scripts/debian.sh"
elsif opts[:box] == 'centos/7' # CentOS7
config.vm.provision 'shell', path: "./scripts/redhat.sh"
elsif opts[:box] == 'generic/ubuntu2004' # Ubuntu 20.04
config.vm.provision 'shell', path: "./scripts/debian.sh"
elsif opts[:box] == 'peru/ubuntu-20.04-desktop-amd64' # Ubuntu with desktop
config.vm.provision 'shell', path: "./scripts/debian.sh"
else
break
end
# Network
config.vm.network :private_network, ip: opts[:ip],
:libvirt__forward_mode => "route",
:libvirt__dhcp_enabled => false
end
end
end