-
Notifications
You must be signed in to change notification settings - Fork 26
/
Makefile
178 lines (152 loc) · 5 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
export LC_ALL = C.UTF-8
CONFIGURATION ?= main
ENVIRONMENT ?= the_environment
CLOUD ?= $(ENVIRONMENT)
IMAGE_USERNAME ?= ubuntu
VERSION_CEPH ?= quincy
VERSION_MANAGER ?= latest
VERSION_OPENSTACK ?= 2024.1
CEPH_STACK ?= ceph-ansible
# renovate: datasource=github-releases depName=opentofu/opentofu
TOFU_VERSION ?= 1.8.7
TERRAFORM ?= tofu
TERRAFORM_BLUEPRINT ?= testbed-default
venv = . venv/bin/activate
export PATH := ${PATH}:${PWD}/venv/bin
.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
.PHONY: setup
setup: ## Prepare the repository.
@contrib/setup-testbed.py \
--environment $(ENVIRONMENT) \
--cloud $(CLOUD) \
.PHONY: clean
clean: setup ## Destroy infrastructure with OpenTofu.
make -C terraform \
CLOUD=$(CLOUD) \
ENVIRONMENT=$(ENVIRONMENT) \
TERRAFORM=$(TERRAFORM) \
clean
.PHONY: wipe-local-install
wipe-local-install: ## Wipe the software dependencies in `venv`.
rm -rf venv .src
.PHONY: create
create: prepare ## Create required infrastructure with OpenTofu.
@contrib/setup-testbed.py \
--environment $(ENVIRONMENT) \
--cloud $(CLOUD)
make -C terraform \
CEPH_STACK=$(CEPH_STACK) \
CLOUD=$(CLOUD) \
CONFIGURATION=$(CONFIGURATION) \
ENVIRONMENT=$(ENVIRONMENT) \
IMAGE_USERNAME=$(IMAGE_USERNAME) \
TERRAFORM=$(TERRAFORM) \
VERSION_CEPH=$(VERSION_CEPH) \
VERSION_MANAGER=$(VERSION_MANAGER) \
VERSION_OPENSTACK=$(VERSION_OPENSTACK) \
create
.PHONY: login
login: setup ## Log in on the manager.
@make -C terraform \
CLOUD=$(CLOUD) \
ENVIRONMENT=$(ENVIRONMENT) \
login
.PHONY: vpn-wireguard
vpn-wireguard: setup ## Establish a wireguard vpn tunnel.
@make -C terraform \
CLOUD=$(CLOUD) \
ENVIRONMENT=$(ENVIRONMENT) \
vpn-wireguard
.PHONY: vpn-wireguard-config
vpn-wireguard-config: setup ## Get the configuration for the wireguard vpn tunnel.
@make -C terraform \
CLOUD=$(CLOUD) \
ENVIRONMENT=$(ENVIRONMENT) \
vpn-wireguard-config
.PHONY: vpn-sshuttle
vpn-sshuttle: setup ## Establish a sshuttle vpn tunnel.
@make -C terraform \
CLOUD=$(CLOUD) \
ENVIRONMENT=$(ENVIRONMENT) \
vpn-sshuttle
.PHONY: bootstrap
bootstrap: setup create ## Bootstrap everything.
${venv} ; ansible-playbook playbooks/deploy.yml \
-i ansible/localhost_inventory.yaml \
-e ansible_galaxy=ansible-galaxy \
-e ansible_playbook=ansible-playbook \
-e basepath="$(PWD)" \
-e testbed_cloud=$(CLOUD) \
-e repo_path="$(PWD)/.src/$(shell contrib/setup-testbed.py --query "repository_server")" \
-e manual_create=true \
-e manual_deploy=true \
-e version_ceph=$(VERSION_CEPH) \
-e version_manager=$(VERSION_MANAGER) \
-e version_openstack=$(VERSION_OPENSTACK) \
-e ceph_stack=$(CEPH_STACK)
.PHONY: manager
manager: setup bootstrap ## Deploy only the manager service.
make -C terraform \
CLOUD=$(CLOUD) \
ENVIRONMENT=$(ENVIRONMENT) \
TERRAFORM=$(TERRAFORM) \
deploy-manager
.PHONY: identity
identity: setup manager ## Deploy only identity services.
make -C terraform \
CLOUD=$(CLOUD) \
ENVIRONMENT=$(ENVIRONMENT) \
TERRAFORM=$(TERRAFORM) \
deploy-identity
.PHONY: ceph
ceph: setup manager ## Deploy only ceph services.
make -C terraform \
CLOUD=$(CLOUD) \
ENVIRONMENT=$(ENVIRONMENT) \
deploy-ceph
.PHONY: deploy
deploy: setup bootstrap ## Deploy everything and then check it.
make -C terraform \
CLOUD=$(CLOUD) \
ENVIRONMENT=$(ENVIRONMENT) \
TERRAFORM=$(TERRAFORM) \
deploy
make -C terraform \
CLOUD=$(CLOUD) \
ENVIRONMENT=$(ENVIRONMENT) \
TERRAFORM=$(TERRAFORM) \
bootstrap
make -C terraform \
CLOUD=$(CLOUD) \
ENVIRONMENT=$(ENVIRONMENT) \
TERRAFORM=$(TERRAFORM) \
check
.PHONY: prepare
prepare: deps ## Run local preperations.
${venv}; ansible-playbook -i localhost, ansible/check-local-versions.yml
@contrib/setup-testbed.py --prepare
.PHONY: sync
sync: venv/bin/activate
@${venv} && gilt overlay && gilt overlay
venv/bin/activate: Makefile
@which python3 > /dev/null || { echo "Missing requirement: python3" >&2; exit 1; }
@which jq > /dev/null || { echo "Missing requirement: jq" >&2; exit 1; }
@python3 -m venv venv --prompt testbed || { echo "Unable to create venv" >&2; exit 1; }
@${venv} && pip3 install -r requirements.txt
touch venv/bin/activate
venv/bin/tofu: venv/bin/activate
$(eval OS := $(shell uname | tr '[:upper:]' '[:lower:]'))
$(eval ARCH := $(shell uname -m | sed -e 's/aarch64/arm64/' -e 's/x86_64/amd64/'))
@echo Downloading opentofu version ${TOFU_VERSION}
curl -s -L --output venv/bin/tofu.zip \
"https://github.com/opentofu/opentofu/releases/download/v${TOFU_VERSION}/tofu_${TOFU_VERSION}_${OS}_${ARCH}.zip"
rm -f venv/bin/tofu
unzip -d venv/bin/ venv/bin/tofu.zip tofu
chmod +x venv/bin/tofu
rm -f venv/bin/tofu.zip
tofu version
touch venv/bin/tofu
.PHONY: deps
deps: venv/bin/tofu venv/bin/activate ## Install software preconditions to `venv`.