forked from shinesolutions/aem-aws-stack-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
335 lines (254 loc) · 14.6 KB
/
Makefile
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
version ?= 5.16.2-pre.0
aem_stack_manager_messenger_version = 2.14.1
aem_test_suite_version = 2.0.0
aem_helloworld_custom_stack_provisioner_version = 0.15.0
ci: clean deps lint package
clean:
rm -rf logs/ stage/ *.cert *.key provisioners/ansible/playbooks/apps/*.retry provisioners/ansible/playbooks/network/network-resources-generated.yaml
stage:
mkdir -p stage/ stage/user-config/ stage/descriptors/
config:
scripts/set-config.sh "${config_path}"
library: stage
scripts/fetch-library.sh "${config_path}"
package:
rm -rf stage
mkdir -p stage
tar \
--exclude='.git*' \
--exclude='.librarian*' \
--exclude='.tmp*' \
--exclude='.yamllint' \
--exclude='stage*' \
--exclude='.idea*' \
--exclude='.DS_Store*' \
--exclude='logs*' \
--exclude='*.retry' \
--exclude='*.iml' \
-cvf \
stage/aem-aws-stack-builder-$(version).tar ./
gzip stage/aem-aws-stack-builder-$(version).tar
release-major:
rtk release --release-increment-type major
release-minor:
rtk release --release-increment-type minor
release-patch:
rtk release --release-increment-type patch
release: release-minor
publish:
gh release create $(version) --title $(version) --notes "" || echo "Release $(version) has been created on GitHub"
gh release upload $(version) stage/aem-aws-stack-builder-$(version).tar.gz
################################################################################
# Code styling check and validation targets:
# - lint Ansible inventory and playbook files
# - check shell scripts
################################################################################
lint:
yamllint \
conf/ansible/inventory/group_vars/*.yaml \
provisioners/ansible/playbooks/*.yaml \
provisioners/ansible/playbooks/*/*.yaml \
provisioners/ansible/playbooks/*/*/*.yaml \
templates/cloudformation/*/*.yaml \
templates/cloudformation/*/*/*.yaml
shellcheck scripts/*.sh test/integration/*.sh
for playbook in provisioners/ansible/playbooks/*/*.yaml; do \
ANSIBLE_LIBRARY=conf/ansible/library ansible-playbook -vvv $$playbook --syntax-check; \
done
# TODO: re-enable template validation after sorting out CI credential
# for template in $$(find templates/cloudformation/ -type f -not -path "templates/cloudformation/apps/aem-stack-manager/ssm-commands/*" -name '*.yaml'); do \
# echo "Checking template $$template ...."; \
# AWS_DEFAULT_REGION=ap-southeast-2 aws cloudformation validate-template --template-body "file://$$template"; \
# done
################################################################################
# Dependencies resolution targets.
# For deps-local and deps-test-local targets, the local dependencies must be
# available on the same directory level where aem-aws-stack-builder is at. The
# idea is that you can test AEM AWS Stack Builder while also developing those
# dependencies locally.
################################################################################
# resolve dependencies from remote artifact registries
deps: stage
pip3 install -r requirements.txt
# resolve test dependencies from remote artifact registries
deps-test: stage
# setup AEM Hello World Config from GitHub
rm -rf stage/aem-helloworld-config/ stage/user-config/* stage/descriptors/*
cd stage && git clone https://github.com/shinesolutions/aem-helloworld-config
cp -R stage/aem-helloworld-config/aem-aws-stack-builder/* stage/user-config/
cp -R stage/aem-helloworld-config/descriptors/* stage/descriptors/
# setup AEM HelloWorld Custom Stack Provisioner from GitHub
wget "https://github.com/shinesolutions/aem-helloworld-custom-stack-provisioner/releases/download/${aem_helloworld_custom_stack_provisioner_version}/aem-helloworld-custom-stack-provisioner-${aem_helloworld_custom_stack_provisioner_version}.tar.gz" \
-O stage/aem-custom-stack-provisioner.tar.gz
# setup AEM Test Suite from GitHub
rm -rf stage/aem-test-suite*/
wget "https://github.com/shinesolutions/aem-test-suite/releases/download/${aem_test_suite_version}/aem-test-suite-${aem_test_suite_version}.tar.gz" --directory-prefix=stage
mkdir -p stage/aem-test-suite
tar -xvzf "stage/aem-test-suite-${aem_test_suite_version}.tar.gz" --directory stage/aem-test-suite/
cd stage/aem-test-suite/ #& make deps
# setup AEM Stack Manager Messenger from GitHub
rm -rf stage/aem-stack-manager-messenger*/
wget "https://github.com/shinesolutions/aem-stack-manager-messenger/releases/download/${aem_stack_manager_messenger_version}/aem-stack-manager-messenger-${aem_stack_manager_messenger_version}.tar.gz" --directory-prefix=stage
mkdir -p stage/aem-stack-manager-messenger/
tar -xvzf "stage/aem-stack-manager-messenger-${aem_stack_manager_messenger_version}.tar.gz" --directory stage/aem-stack-manager-messenger/
cd stage/aem-stack-manager-messenger/ #& make deps
# resolve test dependencies from local directories
deps-test-local: stage
# setup AEM AWS Stack Provisioner from local clone
cd ../aem-aws-stack-provisioner && version=$(test_id) make deps-local package && aws s3 cp stage/aem-aws-stack-provisioner-$(test_id).tar.gz s3://aem-opencloud/library/
# setup AEM Stack Manager from local clone
cd ../aem-stack-manager-cloud && version=$(test_id) make deps package && aws s3 cp stage/aem-stack-manager-cloud-$(test_id).zip s3://aem-opencloud/library/
# setup AEM Hello World Config from local clone
rm -rf stage/aem-helloworld-config/ stage/user-config/* stage/descriptors/*
cp -R ../aem-helloworld-config/aem-aws-stack-builder/* stage/user-config/
cp -R ../aem-helloworld-config/descriptors/* stage/descriptors/
# setup AEM Hello World Custom Stack Provisioner from local clone
cd ../aem-helloworld-custom-stack-provisioner && make package
rm -rf stage/aem-custom-stack-provisioner.tar.gz
cp ../aem-helloworld-custom-stack-provisioner/stage/*.tar.gz stage/aem-custom-stack-provisioner.tar.gz
# setup AEM Test Suite from local clone
rm -rf stage/aem-test-suite/
mkdir -p stage/aem-test-suite/
cp -R ../aem-test-suite/* stage/aem-test-suite/
# setup AEM Stack Manager Messenger from local clone
rm -rf stage/aem-stack-manager-messenger/
mkdir -p stage/aem-stack-manager-messenger/
cp -R ../aem-stack-manager-messenger/* stage/aem-stack-manager-messenger/
################################################################################
# Network targets.
################################################################################
generate-network-config:
./scripts/generate-network-config.sh "$(config_path)"
create-vpc:
./scripts/create-stack.sh network/vpc "$(config_path)" "$(stack_prefix)"
delete-vpc:
./scripts/delete-stack.sh network/vpc "$(config_path)" "$(stack_prefix)"
create-network:
./scripts/create-stack.sh network/network "$(config_path)" "$(stack_prefix)"
delete-network:
./scripts/delete-stack.sh network/network "$(config_path)" "$(stack_prefix)"
create-network-exports:
./scripts/create-stack.sh network/network-exports "$(config_path)" "$(stack_prefix)"
delete-network-exports:
./scripts/delete-stack.sh network/network-exports "$(config_path)" "$(stack_prefix)"
create-nat-gateway:
./scripts/create-stack.sh network/nat-gateway "$(config_path)" "$(stack_prefix)"
delete-nat-gateway:
./scripts/delete-stack.sh network/nat-gateway "$(config_path)" "$(stack_prefix)"
create-bastion:
./scripts/create-stack.sh network/bastion "$(config_path)" "$(stack_prefix)"
delete-bastion:
./scripts/delete-stack.sh network/bastion "$(config_path)" "$(stack_prefix)"
################################################################################
# AWS resources targets.
################################################################################
create-aws-resources:
scripts/create-stack.sh apps/create-aws-resources "${config_path}" "${stack_prefix}"
delete-aws-resources:
scripts/delete-stack.sh apps/delete-aws-resources "${config_path}" "${stack_prefix}"
################################################################################
# AEM Stack Data targets.
################################################################################
create-aem-stack-data:
./scripts/create-stack.sh apps/aem/stack-data "$(config_path)" "$(stack_prefix)"
delete-aem-stack-data:
./scripts/delete-stack.sh apps/aem/stack-data "$(config_path)" "$(stack_prefix)"
################################################################################
# AEM Consolidated architecture targets.
################################################################################
create-consolidated-prerequisites:
./scripts/create-stack.sh apps/aem/consolidated/prerequisites "$(config_path)" "$(stack_prefix)"
delete-consolidated-prerequisites:
./scripts/delete-stack.sh apps/aem/consolidated/prerequisites "$(config_path)" "$(stack_prefix)"
create-consolidated-main: create-aem-stack-data
./scripts/create-stack.sh apps/aem/consolidated/main "$(config_path)" "$(stack_prefix)" "$(prerequisites_stack_prefix)"
delete-consolidated-main: delete-aem-stack-data
./scripts/delete-stack.sh apps/aem/consolidated/main "$(config_path)" "$(stack_prefix)"
switch-dns-consolidated:
./scripts/switch-dns-consolidated.sh apps/aem/consolidated/switch-dns "$(config_path)" "$(stack_prefix)" "$(author_publish_dispatcher_hosted_zone)" "$(author_publish_dispatcher_record_set)"
create-consolidated:
make create-consolidated-prerequisites "config_path=$(config_path)" "stack_prefix=$(stack_prefix)"
make create-consolidated-main "config_path=$(config_path)" "stack_prefix=$(stack_prefix)" "prerequisites_stack_prefix=$(stack_prefix)"
delete-consolidated: delete-consolidated-main delete-consolidated-prerequisites
################################################################################
# AEM Full Set architecture targets.
################################################################################
create-full-set-prerequisites:
./scripts/create-stack.sh apps/aem/full-set/prerequisites "$(config_path)" "$(stack_prefix)"
delete-full-set-prerequisites:
./scripts/delete-stack.sh apps/aem/full-set/prerequisites "$(config_path)" "$(stack_prefix)"
create-full-set-main: create-aem-stack-data
./scripts/create-stack.sh apps/aem/full-set/main "$(config_path)" "$(stack_prefix)" "$(prerequisites_stack_prefix)"
delete-full-set-main: delete-aem-stack-data
./scripts/delete-stack.sh apps/aem/full-set/main "$(config_path)" "$(stack_prefix)"
switch-dns-full-set:
./scripts/switch-dns-full-set.sh apps/aem/full-set/switch-dns "$(config_path)" "$(stack_prefix)" "$(publish_dispatcher_hosted_zone)" "$(publish_dispatcher_record_set)" "$(author_dispatcher_hosted_zone)" "$(author_dispatcher_record_set)"
create-full-set:
make create-full-set-prerequisites "config_path=$(config_path)" "stack_prefix=$(stack_prefix)"
make create-full-set-main "config_path=$(config_path)" "stack_prefix=$(stack_prefix)" "prerequisites_stack_prefix=$(stack_prefix)"
delete-full-set: delete-full-set-main delete-full-set-prerequisites
################################################################################
# AEM Stack Manager targets.
################################################################################
create-aem-stack-manager-stack-data:
./scripts/create-stack.sh apps/aem-stack-manager/stack-data "$(config_path)" "$(stack_prefix)"
delete-aem-stack-manager-stack-data:
./scripts/delete-stack.sh apps/aem-stack-manager/stack-data "$(config_path)" "$(stack_prefix)"
create-stack-manager: create-aem-stack-manager-stack-data
./scripts/create-stack.sh apps/aem-stack-manager/main "$(config_path)" "$(stack_prefix)"
delete-stack-manager:
./scripts/delete-stack.sh apps/aem-stack-manager/main "$(config_path)" "$(stack_prefix)"
################################################################################
# CloudFront CDN targets.
################################################################################
create-cdn:
./scripts/create-stack.sh apps/cdn/main "$(config_path)" "$(stack_prefix)"
delete-cdn:
./scripts/delete-stack.sh apps/cdn/main "$(config_path)" "$(stack_prefix)"
################################################################################
# Integration test targets.
# Provides convenient targets for testing against the supported permutation of
# AEM versions and OSes.
################################################################################
test-integration-aem62-rhel7: deps deps-test
./test/integration/test-examples.sh $(test_id) aem62 rhel7
test-integration-aem62-amazon-linux2: deps deps-test
./test/integration/test-examples.sh $(test_id) aem62 amazon-linux2
test-integration-aem63-rhel7: deps deps-test
./test/integration/test-examples.sh $(test_id) aem63 rhel7
test-integration-aem63-amazon-linux2: deps deps-test
./test/integration/test-examples.sh $(test_id) aem63 amazon-linux2
test-integration-aem64-rhel7: deps deps-test
./test/integration/test-examples.sh $(test_id) aem64 rhel7
test-integration-aem64-amazon-linux2: deps deps-test
./test/integration/test-examples.sh $(test_id) aem64 amazon-linux2
test-integration-aem65-rhel7: deps deps-test
./test/integration/test-examples.sh $(test_id) aem65 rhel7
test-integration-aem65-amazon-linux2: deps deps-test
./test/integration/test-examples.sh $(test_id) aem65 amazon-linux2
test-integration-local-aem62-rhel7: deps deps-test-local
./test/integration/test-examples-local.sh $(test_id) aem62 rhel7
test-integration-local-aem62-amazon-linux2: deps deps-test-local
./test/integration/test-examples-local.sh $(test_id) aem62 amazon-linux2
test-integration-local-aem63-rhel7: deps deps-test-local
./test/integration/test-examples-local.sh $(test_id) aem63 rhel7
test-integration-local-aem64-rhel7: deps deps-test-local
./test/integration/test-examples-local.sh $(test_id) aem64 rhel7
test-integration-local-aem64-amazon-linux2: deps deps-test-local
./test/integration/test-examples-local.sh $(test_id) aem64 amazon-linux2
test-integration-local-aem65-rhel7: deps deps-test-local
./test/integration/test-examples-local.sh $(test_id) aem65 rhel7
test-integration-local-aem65-amazon-linux2: deps deps-test-local
./test/integration/test-examples-local.sh $(test_id) aem65 amazon-linux2
########################################
# Utility stacks
########################################
create-snapshots-purge:
./scripts/create-stack.sh apps/utilities "$(config_path)" "$(stack_prefix)"
delete-snapshots-purge:
./scripts/delete-stack.sh apps/utilities "$(config_path)" "$(stack_prefix)"
create-ssm-documents:
./scripts/create-stack.sh apps/stack-manager/ssm-documents "$(config_path)" "$(stack_prefix)"
delete-ssm-documents:
./scripts/delete-stack.sh apps/stack-manager/ssm-documents "$(config_path)" "$(stack_prefix)"
.PHONY: stage create-aem delete-aem create-network delete-network ci clean deps lint create-cert upload-cert delete-cert package git-archive generate-network-config release release-major release-minor release-patch publish