forked from Azure/AgentBaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
packer.mk
executable file
·93 lines (81 loc) · 3.56 KB
/
packer.mk
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
SHELL=/bin/bash -o pipefail
build-packer:
ifeq (${OS_SKU},Ubuntu)
ifeq (${ARCHITECTURE},ARM64)
ifeq (${MODE},gen2Mode)
@echo "${MODE}: Building with Hyper-v generation 2 ARM64 VM"
@packer build -var-file=vhdbuilder/packer/settings.json vhdbuilder/packer/vhd-image-builder-arm64-gen2.json
@echo "${MODE}: Convert os disk snapshot to SIG"
@./vhdbuilder/packer/convert-osdisk-snapshot-to-sig.sh
else ifeq (${MODE},sigMode)
$(error sigMode not supported yet)
else
$(error arm64 generation 1 VM not supported)
endif
else
ifeq (${MODE},gen2Mode)
@echo "${MODE}: Building with Hyper-v generation 2 VM"
@packer build -var-file=vhdbuilder/packer/settings.json vhdbuilder/packer/vhd-image-builder-gen2.json
else ifeq (${MODE},sigMode)
@echo "${MODE}: Building with Hyper-v generation 1 VM and save to Shared Image Gallery"
@packer build -var-file=vhdbuilder/packer/settings.json vhdbuilder/packer/vhd-image-builder-sig.json
else
@echo "${MODE}: Building with Hyper-v generation 1 VM and save to Classic Storage Account"
@packer build -var-file=vhdbuilder/packer/settings.json vhdbuilder/packer/vhd-image-builder.json
endif
endif
else ifeq (${OS_SKU},CBLMariner)
ifeq (${OS_VERSION},V1)
ifeq (${MODE},gen2Mode)
@echo "${MODE}: Building with Hyper-v generation 2 VM and save to Classic Storage Account"
@packer build -var-file=vhdbuilder/packer/settings.json vhdbuilder/packer/vhd-image-builder-mariner-gen2.json
else ifeq (${MODE},sigMode)
$(error sigMode not supported yet)
else
@echo "${MODE}: Building with Hyper-v generation 1 VM and save to Classic Storage Account"
@packer build -var-file=vhdbuilder/packer/settings.json vhdbuilder/packer/vhd-image-builder-mariner.json
endif
else ifeq (${OS_VERSION},V2)
ifeq (${MODE},gen2Mode)
@echo "${MODE}: Building with Hyper-v generation 2 VM"
@packer build -var-file=vhdbuilder/packer/settings.json vhdbuilder/packer/vhd-image-builder-mariner2-gen2.json
else ifeq (${MODE},sigMode)
$(error sigMode not supported yet)
else
$(error MarinerV2 gen1 VMs are not supported yet)
endif
else
$(error OS_VERSION was invalid ${OS_VERSION})
endif
else
$(error OS_SKU was invalid ${OS_SKU})
endif
build-packer-windows:
ifeq (${MODE},sigMode)
@echo "${MODE}: Building with Hyper-v generation 1 VM and save to Shared Image Gallery"
@packer build -var-file=vhdbuilder/packer/settings.json vhdbuilder/packer/windows-vhd-builder-sig.json
else
@echo "${MODE}: Building with Hyper-v generation 1 VM and save to Classic Storage Account"
@packer build -var-file=vhdbuilder/packer/settings.json vhdbuilder/packer/windows-vhd-builder.json
endif
init-packer:
@./vhdbuilder/packer/init-variables.sh
az-login:
az login --service-principal -u ${CLIENT_ID} -p ${CLIENT_SECRET} --tenant ${TENANT_ID}
az account set -s ${SUBSCRIPTION_ID}
run-packer: az-login
@packer version && ($(MAKE) -f packer.mk init-packer | tee packer-output) && ($(MAKE) -f packer.mk build-packer | tee -a packer-output)
run-packer-windows: az-login
@packer version && ($(MAKE) -f packer.mk init-packer | tee packer-output) && ($(MAKE) -f packer.mk build-packer-windows | tee -a packer-output)
az-copy: az-login
azcopy-preview copy "${OS_DISK_SAS}" "${CLASSIC_BLOB}${CLASSIC_SAS_TOKEN}" --recursive=true
cleanup: az-login
@./vhdbuilder/packer/cleanup.sh
generate-sas: az-login
@./vhdbuilder/packer/generate-vhd-publishing-info.sh
convert-sig-to-classic-storage-account-blob: az-login
@./vhdbuilder/packer/convert-sig-to-classic-storage-account-blob.sh
windows-vhd-publishing-info: az-login
@./vhdbuilder/packer/generate-windows-vhd-publishing-info.sh
test-building-vhd: az-login
@./vhdbuilder/packer/test/run-test.sh