forked from rgl/jenkins-vagrant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
79 lines (69 loc) · 3.89 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
config_jenkins_fqdn = 'jenkins.example.com'
config_jenkins_ip = '10.10.10.100'
config_ubuntu_fqdn = "ubuntu.#{config_jenkins_fqdn}"
config_ubuntu_ip = '10.10.10.101'
config_windows_fqdn = "windows.#{config_jenkins_fqdn}"
config_windows_ip = '10.10.10.102'
config_macos_fqdn = "macos.#{config_jenkins_fqdn}"
config_macos_ip = '10.10.10.103'
Vagrant.configure('2') do |config|
config.vm.box = 'ubuntu-16.04-amd64'
config.vm.provider :virtualbox do |vb|
vb.linked_clone = true
vb.memory = 2048
vb.customize ['modifyvm', :id, '--cableconnected1', 'on']
end
config.vm.define :jenkins do |config|
config.vm.hostname = config_jenkins_fqdn
config.vm.network :private_network, ip: config_jenkins_ip
config.vm.provision :shell, inline: "echo '#{config_ubuntu_ip} #{config_ubuntu_fqdn}' >>/etc/hosts"
config.vm.provision :shell, inline: "echo '#{config_windows_ip} #{config_windows_fqdn}' >>/etc/hosts"
config.vm.provision :shell, inline: "echo '#{config_macos_ip} #{config_macos_fqdn}' >>/etc/hosts"
config.vm.provision :shell, path: 'provision.sh'
end
config.vm.define :ubuntu do |config|
config.vm.hostname = config_ubuntu_fqdn
config.vm.network :private_network, ip: config_ubuntu_ip
config.vm.provision :shell, inline: "echo '#{config_jenkins_ip} #{config_jenkins_fqdn}' >>/etc/hosts"
config.vm.provision :shell, path: 'provision-ubuntu.sh'
end
config.vm.define :windows do |config|
config.vm.provider :virtualbox do |vb|
vb.memory = 4096
end
config.vm.box = 'windows-2016-amd64'
config.vm.hostname = 'windows'
config.vm.network :private_network, ip: config_windows_ip
config.vm.provision :shell, inline: "echo '#{config_jenkins_ip} #{config_jenkins_fqdn}' | Out-File -Encoding ASCII -Append c:/Windows/System32/drivers/etc/hosts"
config.vm.provision :shell, inline: "$env:chocolateyVersion='0.10.5'; iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex", name: "Install Chocolatey"
config.vm.provision :shell, path: 'windows/ps.ps1', args: 'provision-dotnet.ps1'
config.vm.provision :reload
config.vm.provision :shell, path: 'windows/ps.ps1', args: 'provision-base.ps1'
config.vm.provision :shell, path: 'windows/ps.ps1', args: ['provision.ps1', config_jenkins_fqdn, config_windows_fqdn]
end
config.vm.define :macos do |config|
config.vm.provider :virtualbox do |vb|
vb.memory = 4096
end
config.vm.box = 'macOS'
config.vm.hostname = config_macos_fqdn
config.vm.network :private_network, ip: config_macos_ip
config.vm.provision :shell, inline: "echo '#{config_jenkins_ip} #{config_jenkins_fqdn}' >>/etc/hosts"
config.vm.provision :shell, path: 'provision-macos.sh', privileged: false
end
config.trigger.before :up, :vm => ['jenkins'] do
ldap_ca_cert_path = '../windows-domain-controller-vagrant/tmp/ExampleEnterpriseRootCA.der'
run "sh -c 'mkdir -p tmp && cp #{ldap_ca_cert_path} tmp'" if File.file? ldap_ca_cert_path
end
config.trigger.before :up, :vm => 'macos' do
raise "You first need to download Xcode_8.1.xip from https://developer.apple.com/download/more/" unless File.file?('Xcode_8.1.xip') || File.file?('Xcode_8.1.cpio.xz')
end
config.trigger.after :up, :vm => 'macos' do
run "sh -c \"vagrant ssh -c 'cat /vagrant/tmp/#{config_macos_fqdn}.ssh_known_hosts' macos >tmp/#{config_macos_fqdn}.ssh_known_hosts\""
run "sh -c \"vagrant ssh -c 'cat /vagrant/Xcode_8.1.cpio.xz' macos >Xcode_8.1.cpio.xz.tmp && mv Xcode_8.1.cpio.xz{.tmp,}\"" unless File.file? 'Xcode_8.1.cpio.xz'
run "sh -c \"vagrant ssh -c 'cat /vagrant/Xcode_8.1.cpio.xz.shasum' macos >Xcode_8.1.cpio.xz.shasum.tmp && mv Xcode_8.1.cpio.xz.shasum{.tmp,}\"" unless File.file? 'Xcode_8.1.cpio.xz.shasum'
end
config.trigger.after :up, :vm => ['ubuntu', 'windows', 'macos'] do
run "vagrant ssh -c 'cat /vagrant/tmp/*.ssh_known_hosts | sudo tee /etc/ssh/ssh_known_hosts' jenkins"
end
end