-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovision_secrets
executable file
·49 lines (39 loc) · 994 Bytes
/
provision_secrets
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
#!/usr/bin/env bash
set -e
# This is hacky, and only a solution to get me moving. I really hope to replace
# this with a more legit process soon.
target_secret_root="/var/secrets/"
_log() {
GREEN='\033[0;32m'
#RED='\033[0;31m'
#YELLOW='\033[0;33m'
NC='\033[0m' # No Color
printf "${GREEN}==> %s${NC}\n" "$*"
}
# inital setup
# shellcheck disable=SC2029
ssh util_lan "sudo mkdir -p $target_secret_root"
generate_secret() {
host="$1"
name="$2"
content="$3"
cat << EOF | ssh "$host" -T "cat | sudo tee $target_secret_root/$name > /dev/null"
$content
EOF
}
for host in "$@"; do
_log "Provisioning secrets onto $host"
generate_secret \
"$host" \
namecheap \
"NAMECHEAP_API_KEY=$(pass show namecheap.com/kyleondy/api)
NAMECHEAP_API_USER=kyleondy"
generate_secret \
"$host" \
unifi \
"$(pass show unifi.lan.1ella.com/admin)"
generate_secret \
"$host" \
grafana_admin_pass \
"$(pass show grafana.apps.lan.1ella.com/admin)"
done