forked from gusztavvargadr/packer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
126 lines (108 loc) · 3.23 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
117
118
119
120
121
122
123
124
125
126
directory = File.dirname(__FILE__)
require "#{directory}/src/vagrant"
def version
'2012'
end
VagrantMachine.defaults_include(
'autostart' => false,
)
class VagrantWindowsMachine < VagrantMachine
@defaults = {
'providers' => {
'virtualbox' => {
'memory' => '4096',
'cpus' => '2',
},
'hyperv' => {
'memory' => '4096',
'cpus' => '2',
},
},
'provisioners' => {
'shell' => {
'inline' => <<-EOF
cmd /c ver
Get-ComputerInfo
choco list -li
EOF
},
'chef_policyfile' => {
'paths' => [
'Policyfile.rb',
],
},
}
}
end
class VagrantLinuxMachine < VagrantMachine
@defaults = {
'providers' => {
'virtualbox' => {
'memory' => '4096',
'cpus' => '2',
},
'hyperv' => {
'memory' => '4096',
'cpus' => '2',
},
},
'provisioners' => {
'shell' => {
'inline' => <<-EOF
uname -a
lshw
apt list --installed
EOF
},
'chef_policyfile' => {
'paths' => [
'Policyfile.rb',
],
},
}
}
end
VagrantDeployment.configure(directory, 'stack' => 'packer') do |deployment|
create_machine(deployment, 'ws2016s')
create_machine(deployment, 'ws2019s')
create_machine(deployment, 'ws2016sc')
create_machine(deployment, 'ws2019sc')
create_machine(deployment, 'wsips')
create_machine(deployment, 'wsipsc')
create_machine(deployment, 'w101809eltsc')
create_machine(deployment, 'w102004e')
create_machine(deployment, 'w102009e')
create_machine(deployment, 'w10ipe')
create_machine(deployment, 'u1604s')
create_machine(deployment, 'u1604d')
create_machine(deployment, 'ws2019s-de')
create_machine(deployment, 'ws2019sc-de')
create_machine(deployment, 'w102009e-dc')
create_machine(deployment, 'u1604s-dc')
create_machine(deployment, 'u1604d-dc')
create_machine(deployment, 'ws2019s-iis')
create_machine(deployment, 'ws2019sc-iis')
create_machine(deployment, 'ws2019s-sql17d')
create_machine(deployment, 'ws2019s-sql19d')
create_machine(deployment, 'w102009e-dc-vs17c')
create_machine(deployment, 'w102009e-dc-vs19c')
create_machine(deployment, 'w102009e-dc-vs17p')
create_machine(deployment, 'w102009e-dc-vs19p')
end
def create_machine(deployment, name)
VagrantMachine.configure(deployment, create_machine_class(name).defaults.merge('name' => name, 'box' => "gusztavvargadr/#{name}-build")) do |machine|
VagrantVirtualBoxProvider.configure(machine, machine.options.fetch('providers').fetch('virtualbox')) do |provider|
provider.override.vm.box_url = "file://#{build_dir}/#{name}/virtualbox-vagrant/output/package/vagrant.box"
end
VagrantHyperVProvider.configure(machine, machine.options.fetch('providers').fetch('hyperv')) do |provider|
provider.override.vm.box_url = "file://#{build_dir}/#{name}/hyperv-vagrant/output/package/vagrant.box"
end
end
end
def create_machine_class(name)
class_name = name.include?('u16') ? 'VagrantLinuxMachine' : 'VagrantWindowsMachine'
Object.const_get(class_name)
end
def build_dir
ENV['PACKER_BUILD_DIR'] ? ENV['PACKER_BUILD_DIR'] : "#{File.dirname(__FILE__)}/build"
end