forked from blauwe-lucht/ansible-alma8
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
69 lines (60 loc) · 2.55 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
Vagrant.configure("2") do |config|
config.vm.define "acs" do |acs|
acs.vm.box = "generic/alma8"
acs.vm.hostname = "acs"
acs.vm.network "private_network", ip: "192.168.15.56"
# Make sure VirtualBox doesn't make new networks for no reason (fix)
config.vm.provider :virtualbox do |vb|
vb.customize [
"modifyvm",
:id,
"--nic2",
"hostonly",
"--cableconnected2",
"on",
"--hostonlyadapter2",
"VirtualBox Host-Only Ethernet Adapter"
]
end
# Make sure all sensitive info is only readable by user.
acs.vm.synced_folder ".", "/vagrant", mount_options: ["dmode=700,fmode=600"]
# Do the initial setup of the ACS with a script.
acs.vm.provision "shell" do |shell|
shell.inline = <<-SHELL
set -euxo pipefail
# netstat -rn shows something like:
# Kernel IP routing table
# Destination Gateway Genmask Flags MSS Window irtt Iface
# 0.0.0.0 10.0.2.2 0.0.0.0 UG 0 0 0 eth0
# 10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
# 192.168.15.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
# We retrieve the Gateway from this output:
host_ip=$(netstat -rn | grep '^0.0.0.0' | awk '{print $2}')
echo "http_proxy=http://$host_ip:9000" >> /etc/environment
echo "https_proxy=http://$host_ip:9000" >> /etc/environment
export http_proxy=http://$host_ip:9000
export https_proxy=http://$host_ip:9000
yum install -y epel-release
yum install -y ansible
SHELL
end
end
config.vm.define "node1" do |node1|
node1.vm.box = "centos/7"
node1.vm.hostname = "node1"
node1.vm.network "private_network", ip: "192.168.15.57"
# Make sure VirtualBox doesn't make new networks for no reason (fix)
config.vm.provider :virtualbox do |vb|
vb.customize [
"modifyvm",
:id,
"--nic2",
"hostonly",
"--cableconnected2",
"on",
"--hostonlyadapter2",
"VirtualBox Host-Only Ethernet Adapter"
]
end
end
end