-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
65 lines (54 loc) · 2.12 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
# vim: ft=ruby
require "io/console"
machine_files = Dir.glob(
"#{File.dirname(__FILE__)}/.vagrant/machines/**/virtualbox/*")
vagrant_cmd = ARGV[0].match?(/^--/) ? ARGV[1] : ARGV[0]
if machine_files.empty? and vagrant_cmd == "up"
puts "Enter Red Hat account credentials\n\n"
print "Username: "
rh_username = $stdin.gets.chomp
print "Password: "
rh_password = $stdin.noecho(&:gets).chomp
puts "\n"
end
ENV["VAGRANT_EXPERIMENTAL"] = "disks"
Vagrant.configure("2") do |config|
# create two servers with the same base configuration
(1..2).each do |i|
config.vm.define "server#{i}" do |server|
server.vm.box = "generic/rhel8"
server.vm.hostname = "server#{i}.vagrant.internal"
server.vm.network "private_network", ip: "192.168.33.1#{i}"
server.vm.provider "virtualbox" do |v|
v.name = "rhcsa8-server#{i}"
v.memory = 1024
v.cpus = 1
end
# server1 - add a network interface
if i == 1
# "auto_config: false" doesn't work so disable the device manually
server.vm.network "private_network", ip: "192.168.33.21"
server.vm.provision "shell", inline: <<-SHELL
nmcli device disconnect eth2
nmcli connection delete 'Wired connection 1'
nmcli connection delete 'Wired connection 2'
sed -i 's/ONBOOT=yes/ONBOOT=no/' /etc/sysconfig/network-scripts/ifcfg-eth2
SHELL
end
# server2 - add some disks
if i == 2
server.vm.disk :disk, size: "5GB", name: "server2-disk001"
server.vm.disk :disk, size: "5GB", name: "server2-disk002"
server.vm.disk :disk, size: "2GB", name: "server2-disk003"
end
server.vm.provision "shell",
name: "Register system with Red Hat Subscription Manager",
inline: "subscription-manager register --username #{rh_username} --password #{rh_password} --auto-attach"
server.trigger.before :destroy do |t|
t.name = "Unregister system from Red Hat Subscription Manager"
t.run_remote = {inline: "subscription-manager unregister"}
end
server.vm.provision "shell", path: "provision.sh"
end
end
end