forked from fidencio/sssd-test-suite
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Vagrantfile
116 lines (98 loc) · 3.59 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
106
107
108
109
110
111
112
113
114
115
116
BOX_LINUX = "fedora/27-cloud-base"
BOX_AD = "peru/windows-server-2016-standard-x64-eval"
BOX_SUSE = "hawk/leap-15.0-ha"
# Return the right box accordingly with the Distro
def ClientBox()
dist = ENV['DIST']
if dist == "suse"
return BOX_SUSE
else
return BOX_LINUX
end
end
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
sync = {
"./shared-data" => "/shared/data",
"./shared-enrollment" => "/shared/enrollment"
}
# "hostpath:guestpath hostpath:guestpath ..."
if ENV.has_key?('SSSD_TEST_SUITE_MOUNT')
ENV['SSSD_TEST_SUITE_MOUNT'].split(" ").each do |mount|
host, guest = mount.split(":")
sync[host] = guest
end
end
sync.each do |host, guest|
this.vm.synced_folder "#{host}", "#{guest}", type: "nfs", nfs_udp: false
end
if ENV.has_key?('SSSD_TEST_SUITE_BASHRC')
this.ssh.forward_env = ["SSSD_TEST_SUITE_BASHRC"]
end
this.vm.provision :shell do |shell|
if box == BOX_SUSE
shell.path = "./provision/install-packages-suse.sh"
else
shell.path = "./provision/install-packages.sh"
end
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",
# Raise these timeouts if you have problems during AD deployment.
"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( "#{ClientBox()}", 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