-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathVagrantfile
105 lines (92 loc) · 2.81 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
103
104
105
# -*- mode: ruby -*-
# vi: ft=ruby :
# file : Vagrantfile
# purpose : build vagrant rhcsa-rhce-lab-environment
#
# author : harald van der laan
# date : 2017/03/16
# version : v1.0.1
#
# changelog:
# - v1.0.1 fixed non working System eth1
# - v1.0.0 initial version
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# disable vagrant-vbguest auto update
if defined? VagrantVbguest
config.vbguest.auto_update = false
end
# setting lanhuage locale environment variable
ENV["LC_ALL"] = "en_US.UTF-8"
ENV["LANG"] = "en_US.UTF-8"
# configure labipa server
config.vm.define "labipa" do |node|
node.vm.box = "centos/7"
node.vm.hostname = "labipa.example.com"
node.vm.network "private_network", ip: "172.16.20.2", auto_config: false
# provider settings for labipa
node.vm.provider "virtualbox" do |vbox|
vbox.customize [
"modifyvm", :id,
"--memory", 1024,
"--cpus", 1,
"--name", "labipa",
]
end
# provisioning for labipa
node.vm.provision "ansible" do |ansible|
ansible.playbook = "provision/labipa.yml"
ansible.host_vars = { "labipa" => { "private_ipv4_address" => "172.16.20.2", "private_ipv6_address" => "fd00:cafe::2" }}
end
end
# condigure system1 and system2 srvers
(1..2).each do |i|
config.vm.define "system#{i}" do |node|
node.vm.box = "centos/7"
node.vm.hostname = "system#{i}.example.com"
node.vm.network "private_network", ip: "172.16.20.#{i}0", auto_config: false
node.vm.network "private_network", ip: "172.16.20.1#{i}0", auto_config: false
node.vm.network "private_network", ip: "172.16.20.2#{i}0", auto_config: false
# provider settings for system1 and system2
node.vm.provider "virtualbox" do |vbox|
vbox.customize [
"modifyvm", :id,
"--memory", 512,
"--cpus", 1,
"--name", "system#{i}"
]
line = `VBoxManage list systemproperties | grep "Default machine folder"`
vb_machine_folder = line.split(':')[1].strip()
disk_name = "disk2.vmdk"
disk = File.join(vb_machine_folder, "system#{i}", disk_name)
unless File.exist?(disk)
vbox.customize [
"createhd",
"--filename", disk,
"--variant", "Fixed",
"--format", "vmdk",
"--size", 1 * 1024,
]
vbox.customize [
"storagectl", :id,
"--name", "SATA Controller",
"--add", "sata",
]
end
vbox.customize [
"storageattach", :id,
"--storagectl", "SATA Controller",
"--port", 2,
"--device", 0,
"--type", "hdd",
"--medium", disk,
]
end
# provision for system1 and system2
node.vm.provision "ansible" do |ansible|
ansible.playbook = "provision/system.yml"
ansible.host_vars = { "system#{i}" => { "private_ipv4_address" => "172.16.20.#{i}0", "private_ipv6_address" => "fd00:cafe::#{i}0" }}
end
end
end
end