This repository has been archived by the owner on Sep 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
105 lines (83 loc) · 3 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
.PHONY: init reconfigure upgrade plan bootstrap provision up down \
init-in-container reconfigure-in-container upgrade-in-container \
plan-in-container bootstrap-in-container provision-in-container \
down-in-container dev-up dev-down
ENV := dev
ifndef OS_ENV
ifneq ($(shell command -v docker),)
ENGINE := docker
else ifneq ($(shell command -v podman),)
ENGINE := podman
else
$(error Container engine can't be found)
endif
endif
ifeq ($(ENV), dev)
ifndef AWS_REGION
AWS_REGION := $(shell aws configure get region)
endif
ifndef PULL_SECRET_ABS_PATH
PULL_SECRET_ABS_PATH := $(PULL_SECRET_ABS_PATH)
else
PULL_SECRET_ABS_PATH := ~/Downloads/pull-secret.txt
endif
else ifeq ($(ENV), ci)
AWS_REGION := ${AWS_REGION}
else ifeq ($(ENV), stage)
AWS_REGION := ${AWS_REGION}
endif
HELPER_IMAGE := ghcr.io/platform-engineering-org/helper:latest
in_container = ${ENGINE} run --rm --name helper -v $(PWD):/workspace:rw -v ~/.aws:/root/.aws:ro -w /workspace --security-opt label=disable --env USER=${USER} --env AWS_REGION=${AWS_REGION} --env OS_ENV=container ${HELPER_IMAGE} echo ${ENV} && make $1
TERRAGRUNT_CMD = cd infra/live/${ENV} && terragrunt run-all --terragrunt-non-interactive
init-in-container:
${TERRAGRUNT_CMD} init
reconfigure-in-container:
${TERRAGRUNT_CMD} init --reconfigure
upgrade-in-container:
${TERRAGRUNT_CMD} init --upgrade
plan-in-container:
${TERRAGRUNT_CMD} plan -var "user=${USER}" -var "aws_region=${AWS_REGION}"
bootstrap-in-container:
${TERRAGRUNT_CMD} apply -auto-approve -var "user=${USER}" -var "aws_region=${AWS_REGION}"
provision-in-container:
ansible-galaxy install -r ./provision/requirements.yml
ANSIBLE_CONFIG="./provision/ansible.cfg" ansible-playbook -e ENV=${ENV} -e AWS_REGION=${AWS_REGION} ./provision/main.yml
down-in-container:
${TERRAGRUNT_CMD} destroy -auto-approve -var "user=${USER}" -var "aws_region=${AWS_REGION}"
init:
$(call in_container,init-in-container)
reconfigure:
$(call in_container,reconfigure-in-container)
upgrade:
$(call in_container,upgrade-in-container)
plan:
$(call in_container,plan-in-container)
bootstrap:
$(call in_container,bootstrap-in-container)
up:
$(call in_container,bootstrap-in-container provision-in-container)
down:
$(call in_container,down-in-container)
provision:
$(call in_container,provision-in-container)
dev-up:
podman run --rm \
-v ${PWD}:/workspace:z \
-v ${PULL_SECRET_ABS_PATH}:/pullsecret/pull-secret.txt:z \
-v ~/.aws:/root/.aws:z \
quay.io/crcont/crc-cloud:v0.0.2 \
create aws \
--project-name "crc-ocp412" \
--backed-url "file:///workspace" \
--output "/workspace" \
--aws-ami-id "ami-019669c0960dbcf14" \
--pullsecret-filepath "/pullsecret/pull-secret.txt" \
--key-filepath "/workspace/id_ecdsa"
dev-down:
podman run --rm \
-v ${PWD}:/workspace:z \
-v ~/.aws:/root/.aws:z \
quay.io/crcont/crc-cloud:v0.0.2 destroy \
--project-name "crc-ocp412" \
--backed-url "file:///workspace" \
--provider "aws"