forked from gusztavvargadr/packer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.cake
143 lines (127 loc) · 5.28 KB
/
core.cake
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#load "./template.cake"
#addin "nuget:?package=Cake.FileHelpers&version=5.0.0"
#addin "nuget:?package=Cake.Json&version=7.0.1"
#addin "nuget:?package=Newtonsoft.Json&version=13.0.1"
var packerTemplates = new List<PackerTemplate>();
IEnumerable<PackerTemplate> PackerTemplates_CreateWindows(string name, string groupName = null, string groupVersion = null, IEnumerable<PackerTemplate> parents = null, IEnumerable<string> aliases = null) {
var items = new List<PackerTemplate>();
var virtualBoxCore = PackerTemplate_Create(
name,
"virtualbox-core",
new [] { PackerBuilder_Create(parents == null ? "virtualbox-iso" : "virtualbox-ovf") },
new [] { PackerProvisioner_Create("chef") },
new [] { PackerPostProcessor_Create("manifest") },
parents != null ? parents.First(item => item.IsMatching("virtualbox-core")) : null
);
var virtualBoxVagrant = PackerTemplate_Create(
name,
"virtualbox-vagrant",
new [] { PackerBuilder_Create("virtualbox-ovf") },
new [] { PackerProvisioner_Create("vagrant") },
new [] { PackerPostProcessor_Create("vagrant-virtualbox") },
virtualBoxCore,
groupName,
groupVersion,
aliases
);
items.Add(virtualBoxCore);
items.Add(virtualBoxVagrant);
var hyperVCore = PackerTemplate_Create(
name,
"hyperv-core",
new [] { PackerBuilder_Create(parents == null ? "hyperv-iso" : "hyperv-vmcx") },
new [] { PackerProvisioner_Create("chef") },
new [] { PackerPostProcessor_Create("manifest") },
parents != null ? parents.First(item => item.IsMatching("hyperv-core")) : null
);
var hyperVVagrant = PackerTemplate_Create(
name,
"hyperv-vagrant",
new [] { PackerBuilder_Create("hyperv-vmcx") },
new [] { PackerProvisioner_Create("vagrant") },
new [] { PackerPostProcessor_Create("vagrant-hyperv") },
hyperVCore,
groupName,
groupVersion,
aliases
);
items.Add(hyperVCore);
items.Add(hyperVVagrant);
packerTemplates.AddRange(items);
return items;
}
IEnumerable<PackerTemplate> PackerTemplates_CreateLinux(string name, string groupName = null, string groupVersion = null, IEnumerable<PackerTemplate> parents = null, IEnumerable<string> aliases = null, bool amazon = false, bool azure = false) {
var items = new List<PackerTemplate>();
var virtualBoxCore = PackerTemplate_Create(
name,
"virtualbox-core",
new [] { PackerBuilder_Create(parents == null ? "virtualbox-iso" : "virtualbox-ovf") },
new [] { PackerProvisioner_Create("shell-prepare"), PackerProvisioner_Create("shell-configure"), PackerProvisioner_Create("shell-install"), PackerProvisioner_Create("shell-cleanup") },
new [] { PackerPostProcessor_Create("manifest") },
parents != null ? parents.First(item => item.IsMatching("virtualbox-core")) : null
);
var virtualBoxVagrant = PackerTemplate_Create(
name,
"virtualbox-vagrant",
new [] { PackerBuilder_Create("virtualbox-ovf") },
new [] { PackerProvisioner_Create("shell-vagrant") },
new [] { PackerPostProcessor_Create("vagrant-virtualbox") },
virtualBoxCore,
groupName,
groupVersion,
aliases
);
items.Add(virtualBoxCore);
items.Add(virtualBoxVagrant);
var hyperVCore = PackerTemplate_Create(
name,
"hyperv-core",
new [] { PackerBuilder_Create(parents == null ? "hyperv-iso" : "hyperv-vmcx") },
new [] { PackerProvisioner_Create("shell-prepare"), PackerProvisioner_Create("shell-configure"), PackerProvisioner_Create("shell-install"), PackerProvisioner_Create("shell-cleanup") },
new [] { PackerPostProcessor_Create("manifest") },
parents != null ? parents.First(item => item.IsMatching("hyperv-core")) : null
);
var hyperVVagrant = PackerTemplate_Create(
name,
"hyperv-vagrant",
new [] { PackerBuilder_Create("hyperv-vmcx") },
new [] { PackerProvisioner_Create("shell-vagrant") },
new [] { PackerPostProcessor_Create("vagrant-hyperv") },
hyperVCore,
groupName,
groupVersion,
aliases
);
items.Add(hyperVCore);
items.Add(hyperVVagrant);
if (amazon) {
var amazonCore = PackerTemplate_Create(
name,
"amazon",
new [] { PackerBuilder_Create("amazon") },
new [] { PackerProvisioner_Create("shell-prepare"), PackerProvisioner_Create("shell-configure"), PackerProvisioner_Create("shell-install"), PackerProvisioner_Create("shell-cleanup") },
new [] { PackerPostProcessor_Create("manifest") },
// new [] { PackerPostProcessor_Create("vagrant-amazon") },
parents != null ? parents.First(item => item.IsMatching("amazon")) : null
);
items.Add(amazonCore);
}
if (azure) {
var azureCore = PackerTemplate_Create(
name,
"azure",
new [] { PackerBuilder_Create(parents == null ? "azure-marketplace" : "azure-custom") },
new [] { PackerProvisioner_Create("shell-prepare"), PackerProvisioner_Create("shell-configure"), PackerProvisioner_Create("shell-install"), PackerProvisioner_Create("shell-cleanup") },
new [] { PackerPostProcessor_Create("manifest") },
parents != null ? parents.First(item => item.IsMatching("azure")) : null
);
items.Add(azureCore);
}
packerTemplates.AddRange(items);
return items;
}
void PackerTemplates_ForEach(string template, Action<PackerTemplate> action) {
foreach (var t in packerTemplates.Where(item => item.IsMatching(template))) {
action(t);
}
}