-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
89 lines (74 loc) · 2.97 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
BOX_LINUX = "fedora/27-cloud-base"
BOX_AD = "peru/windows-server-2016-standard-x64-eval"
def Guest(guest, box, hostname, ip, memory)
guest.vm.box = box
guest.vm.hostname = hostname
guest.vm.network "private_network", ip: ip
guest.vm.provider :libvirt do |libvirt|
libvirt.memory = memory
end
end
# Create a Linux guest.
# Hostname should be fully qualified domain name.
def LinuxGuest(box, config, name, hostname, ip, memory)
config.vm.define name do |this|
Guest(this, box, hostname, ip, memory)
this.vm.synced_folder ".", "/vagrant", disabled: true
this.vm.synced_folder "./shared-data", "/shared/data"
this.vm.synced_folder "./shared-enrollment", "/shared/enrollment"
if ENV.has_key?('SSSD_SOURCE')
this.vm.synced_folder ENV['SSSD_SOURCE'], "/shared/sssd"
end
if ENV.has_key?('INCLUDE_DIR')
this.vm.synced_folder ENV['INCLUDE_DIR'], "/shared/scripts"
end
this.vm.provision :shell do |shell|
shell.path = "./provision/install-packages.sh"
shell.args = name
end
SetupAnsibleProvisioning(this)
end
end
# Create a windows guest.
# Hostname must be a short machine name not a fully qualified domain name.
def WindowsGuest(box, config, name, hostname, ip, memory)
config.vm.define name do |this|
Guest(this, box, hostname, ip, memory)
this.vm.guest = :windows
this.vm.communicator = "winrm"
this.winrm.username = ".\\Administrator"
SetupAnsibleProvisioning(this)
end
end
# We have to setup ansible provisioning everywhere in the same way
# in order to let vagrant create inventory file automatically.
#
# Ansible Windows user needs to be Administrator as it can detect domain
# on run-time. But vagrant command for rdp needs to know the domain.
#
# Also we need to disable certificate validation and increase winrm
# timeout to make ansible work for Windows guests.
def SetupAnsibleProvisioning(config)
windows_settings = {
"ansible_winrm_server_cert_validation" => "ignore",
"ansible_winrm_operation_timeout_sec" => 60,
"ansible_winrm_read_timeout_sec" => 70,
"ansible_user" => "Administrator"
}
config.vm.provision :ansible do |ansible|
ansible.playbook = "./provision/ping.yml"
ansible.host_vars = {
"ad" => windows_settings,
"ad-child" => windows_settings
}
end
end
# Currently each windows machine must be created with different box
# so it has different SID. Otherwise we fail to create a domain controller.
Vagrant.configure("2") do |config|
LinuxGuest( "#{BOX_LINUX}", config, "ipa", "master.ipa.vm", "192.168.100.10", 1792)
LinuxGuest( "#{BOX_LINUX}", config, "ldap", "master.ldap.vm", "192.168.100.20", 512)
LinuxGuest( "#{BOX_LINUX}", config, "client", "master.client.vm", "192.168.100.30", 1024)
WindowsGuest("#{BOX_AD}", config, "ad", "root", "192.168.100.110", 1024)
WindowsGuest("#{BOX_AD}", config, "ad-child", "child", "192.168.100.120", 1024)
end