This repository has been archived by the owner on Oct 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathMakefile
executable file
·100 lines (88 loc) · 2.95 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
.PHONY: init up halt restart destroy sync update ssh
export VAGRANT_PROVIDER ?= "virtualbox"
export UBUNTU_VERSION ?= 23.04
export VAGRANT_CLIENT_RAM ?= 1024
export VAGRANT_CLIENT_CPUS ?= 1
export VAGRANT_SERVER_RAM ?= 512
export VAGRANT_SERVER_CPUS ?= 1
export VAULT_UNSEAL_KEY ?= "INSERT-VAULT-UNSEAL-KEY"
-include .env
#
# init is a shortcut to initialize the HashiBox environment for the first time.
# Apply the environment variables before installing so we know if we need OSS
# or Enterprise version for Consul, Nomad, and Vault. We need to apply them after
# installation as well since `.env` is now populated with Vault unseal key and
# root token. We then can unseal Vault, bootstrap ACLs on Consul and Nomad,
# initialize Vault as CA provider for Consul Connect, and finally sync files with
# the result of the bootstrap process. Last step is to create the Consul and Nomad
# secret engines on Vault. We wait 45 seconds before doing this step to ensure a
# Vault node is "active".
#
init:
vagrant up --provider=${VAGRANT_PROVIDER} --parallel
./scripts/upload.sh
./scripts/dotenv.sh
./scripts/init/install.sh
./scripts/init/vault-init.sh
./scripts/dotenv.sh
./scripts/restart.sh
sleep 5
./scripts/unseal.sh
./scripts/init/consul-bootstrap.sh
./scripts/init/nomad-bootstrap.sh
make sync
sleep 45
./scripts/init/consul-ca.sh
./scripts/init/vault-engines.sh
#
# up is a shortcut to start the Vagrant environment. If you made some changes in
# `.env` or configuration files, you'll need to execute `make sync` after.
#
up:
vagrant up --provider=${VAGRANT_PROVIDER} --parallel
./scripts/restart.sh
sleep 5
./scripts/unseal.sh
#
# halt is a shortcut to stop the Vagrant environment.
#
halt:
vagrant halt
#
# restart is a shortcut to properly stop and restart the Vagrant environment.
#
restart: halt up
#
# destroy is a shortcut to stop and force destroy the Vagrant environment.
#
destroy: halt
vagrant destroy -f --parallel
#
# sync is a shortcut to synchronize the local `uploads` directory with the
# appropriate targeted nodes. It also applies some environment variables, then
# restarts the Consul, Nomad, and Vault services and finally unseal Vault on
# every server nodes.
#
sync:
./scripts/upload.sh
./scripts/dotenv.sh
./scripts/restart.sh
sleep 5
./scripts/unseal.sh
#
# update is a shortcut to update Consul, Nomad, Vault, and Docker on every nodes.
# It also unseal Vault on every server nodes.
#
update:
./scripts/update.sh
sleep 5
./scripts/unseal.sh
#
# ssh is a shortcut to ensure that the Nomad user's known hosts file is
# populated with GitHub and Bitbucket hosts, as described here:
# https://www.nomadproject.io/docs/job-specification/artifact#download-using-git
#
ssh:
bolt command run "sudo mkdir -p /root/.ssh" --targets=us --run-as root
bolt command run "ssh-keyscan github.com | sudo tee -a /root/.ssh/known_hosts" --targets=us --run-as root
bolt command run "ssh-keyscan bitbucket.org | sudo tee -a /root/.ssh/known_hosts" --targets=us --run-as root