generated from Skatteetaten/vagrant-hashistack-template
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
68 lines (53 loc) · 2.45 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
include dev/.env
export PATH := $(shell pwd)/tmp:$(PATH)
.ONESHELL .PHONY: up update-box destroy-box remove-tmp clean example
.DEFAULT_GOAL := up
#### Pre requisites ####
install:
mkdir -p tmp;(cd tmp; git clone --depth=1 https://github.com/fredrikhgrelland/vagrant-hashistack.git; cd vagrant-hashistack; make install); rm -rf tmp/vagrant-hashistack
check_for_consul_binary:
ifeq (, $(shell which consul))
$(error "No consul binary in $(PATH), download the consul binary from here :\n https://www.consul.io/downloads\n\n' && exit 2")
endif
check_for_terraform_binary:
ifeq (, $(shell which terraform))
$(error "No terraform binary in $(PATH), download the terraform binary from here :\n https://www.terraform.io/downloads.html\n\n' && exit 2")
endif
check_for_docker_binary:
ifeq (, $(shell which docker))
$(error "No docker binary in $(PATH), install docker from here :\n https://docs.docker.com/get-docker/\n\n' && exit 2")
endif
#### Development ####
# start commands
dev: update-box custom_ca
SSL_CERT_FILE=${SSL_CERT_FILE} CURL_CA_BUNDLE=${CURL_CA_BUNDLE} CUSTOM_CA=${CUSTOM_CA} ANSIBLE_ARGS='--skip-tags "test"' vagrant up --provision
custom_ca:
ifdef CUSTOM_CA
cp -f ${CUSTOM_CA} docker/conf/certificates/
endif
up: update-box custom_ca
ifeq ($(GITHUB_ACTIONS),true) # Always set to true when GitHub Actions is running the workflow. You can use this variable to differentiate when tests are being run locally or by GitHub Actions.
SSL_CERT_FILE=${SSL_CERT_FILE} CURL_CA_BUNDLE=${CURL_CA_BUNDLE} ANSIBLE_ARGS='--extra-vars "ci_test=true"' vagrant up --provision
else
SSL_CERT_FILE=${SSL_CERT_FILE} CURL_CA_BUNDLE=${CURL_CA_BUNDLE} CUSTOM_CA=${CUSTOM_CA} vagrant up --provision
endif
test: clean up
status:
vagrant global-status
# clean commands
destroy-box:
vagrant destroy -f
remove-tmp:
rm -rf ./tmp
rm -rf ./.vagrant
rm -rf ./dev/tmp
rm -rf ./.minio.sys
rm -rf ./example/**/.terraform
rm -rf ./example/**/.terraform*
clean: destroy-box remove-tmp
# helper commands
update-box:
@SSL_CERT_FILE=${SSL_CERT_FILE} CURL_CA_BUNDLE=${CURL_CA_BUNDLE} vagrant box update || (echo '\n\nIf you get an SSL error you might be behind a transparent proxy. \nMore info https://github.com/fredrikhgrelland/vagrant-hashistack/blob/master/README.md#proxy\n\n' && exit 2)
pre-commit: check_for_docker_binary check_for_terraform_binary
docker run -e RUN_LOCAL=true -v "${PWD}:/tmp/lint/" github/super-linter
terraform fmt -recursive && echo "\e[32mTrying to prettify all .tf files.\e[0m"