|
| 1 | +BOX_LINUX = "fedora/26-cloud-base" |
| 2 | +BOX_AD_ROOT = "peru/windows-server-2016-standard-x64-eval" |
| 3 | +BOX_AD_CHILD = "peru/windows-server-2012-r2-standard-x64-eval" |
| 4 | + |
| 5 | +def Guest(guest, box, hostname, ip, memory) |
| 6 | + guest.vm.box = box |
| 7 | + guest.vm.hostname = hostname |
| 8 | + guest.vm.network "private_network", ip: ip |
| 9 | + |
| 10 | + guest.vm.provider :libvirt do |libvirt| |
| 11 | + libvirt.memory = memory |
| 12 | + end |
| 13 | +end |
| 14 | + |
| 15 | +# Create a Linux guest. |
| 16 | +# Hostname should be fully qualified domain name. |
| 17 | +def LinuxGuest(box, config, name, hostname, ip, memory) |
| 18 | + config.vm.define name do |this| |
| 19 | + Guest(this, box, hostname, ip, memory) |
| 20 | + |
| 21 | + this.vm.synced_folder ".", "/vagrant", disabled: true |
| 22 | + |
| 23 | + this.vm.synced_folder "./shared-data", "/shared/data" |
| 24 | + this.vm.synced_folder "./shared-enrollment", "/shared/enrollment" |
| 25 | + |
| 26 | + if ENV.has_key?('SSSD_SOURCE') |
| 27 | + this.vm.synced_folder ENV['SSSD_SOURCE'], "/shared/sssd" |
| 28 | + end |
| 29 | + |
| 30 | + if ENV.has_key?('INCLUDE_DIR') |
| 31 | + this.vm.synced_folder ENV['INCLUDE_DIR'], "/shared/scripts" |
| 32 | + end |
| 33 | + |
| 34 | + this.vm.provision :shell do |shell| |
| 35 | + shell.path = "./provision/install-packages.sh" |
| 36 | + shell.args = name |
| 37 | + end |
| 38 | + |
| 39 | + SetupAnsibleProvisioning(this) |
| 40 | + end |
| 41 | +end |
| 42 | + |
| 43 | +# Create a windows guest. |
| 44 | +# Hostname must be a short machine name not a fully qualified domain name. |
| 45 | +def WindowsGuest(box, config, name, hostname, ip, memory) |
| 46 | + config.vm.define name do |this| |
| 47 | + Guest(this, box, hostname, ip, memory) |
| 48 | + |
| 49 | + this.vm.guest = :windows |
| 50 | + this.vm.communicator = "winrm" |
| 51 | + this.winrm.username = ".\\Administrator" |
| 52 | + |
| 53 | + SetupAnsibleProvisioning(this) |
| 54 | + end |
| 55 | +end |
| 56 | + |
| 57 | +# We have to setup ansible provisioning everywhere in the same way |
| 58 | +# in order to let vagrant create inventory file automatically. |
| 59 | +# |
| 60 | +# Ansible Windows user needs to be Administrator as it can detect domain |
| 61 | +# on run-time. But vagrant command for rdp needs to know the domain. |
| 62 | +# |
| 63 | +# Also we need to disable certificate validation and increase winrm |
| 64 | +# timeout to make ansible work for Windows guests. |
| 65 | +def SetupAnsibleProvisioning(config) |
| 66 | + windows_settings = { |
| 67 | + "ansible_winrm_server_cert_validation" => "ignore", |
| 68 | + "ansible_winrm_operation_timeout_sec" => 60, |
| 69 | + "ansible_winrm_read_timeout_sec" => 70, |
| 70 | + "ansible_user" => "Administrator" |
| 71 | + } |
| 72 | + |
| 73 | + config.vm.provision :ansible do |ansible| |
| 74 | + ansible.playbook = "./provision/ping.yml" |
| 75 | + ansible.host_vars = { |
| 76 | + "ad" => windows_settings, |
| 77 | + "ad-child" => windows_settings |
| 78 | + } |
| 79 | + end |
| 80 | +end |
| 81 | + |
| 82 | +# Currently each windows machine must be created with different box |
| 83 | +# so it has different SID. Otherwise we fail to create a domain controller. |
| 84 | +Vagrant.configure("2") do |config| |
| 85 | + LinuxGuest( "#{BOX_LINUX}", config, "ipa", "master.ipa.vm", "192.168.100.10", 1792) |
| 86 | + LinuxGuest( "#{BOX_LINUX}", config, "ldap", "master.ldap.vm", "192.168.100.20", 512) |
| 87 | + LinuxGuest( "#{BOX_LINUX}", config, "client", "master.client.vm", "192.168.100.30", 1024) |
| 88 | + WindowsGuest("#{BOX_AD_ROOT}", config, "ad", "root", "192.168.100.110", 1024) |
| 89 | + WindowsGuest("#{BOX_AD_CHILD}", config, "ad-child", "child", "192.168.100.120", 1024) |
| 90 | +end |
0 commit comments