Also generated tfvars from apps.config.
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -17,4 +17,6 @@ app
|
|||||||
|
|
||||||
apps.config
|
apps.config
|
||||||
|
|
||||||
|
# generated files
|
||||||
all-apps/lb/Caddyfile
|
all-apps/lb/Caddyfile
|
||||||
|
generated.tfvars
|
||||||
11
Makefile
11
Makefile
@@ -12,11 +12,14 @@ all-apps/lb/Caddyfile: apps.config make-caddyfile.sh
|
|||||||
ignition.json: cl.yaml app/.dirstamp all-apps/lb/Caddyfile
|
ignition.json: cl.yaml app/.dirstamp all-apps/lb/Caddyfile
|
||||||
cat cl.yaml | sudo docker run --rm --volume /home/tjhintz/.ssh/id_rsa.pub:/pwd/ssh-keys --volume ${PWD}:/pwd --workdir /pwd -i quay.io/coreos/butane:latest -d /pwd > ignition.json
|
cat cl.yaml | sudo docker run --rm --volume /home/tjhintz/.ssh/id_rsa.pub:/pwd/ssh-keys --volume ${PWD}:/pwd --workdir /pwd -i quay.io/coreos/butane:latest -d /pwd > ignition.json
|
||||||
|
|
||||||
plan: ignition.json
|
generated.tfvars: apps.config make-generated.sh
|
||||||
terraform plan -var-file $(TERRAFORM_ENV).tfvars
|
./make-generated.sh > generated.tfvars
|
||||||
|
|
||||||
apply: ignition.json
|
plan: ignition.json $(TERRAFORM_ENV).tfvars generated.tfvars
|
||||||
terraform apply -var-file $(TERRAFORM_ENV).tfvars
|
bash -c "terraform plan -var-file=<(cat $(TERRAFORM_ENV).tfvars generated.tfvars)"
|
||||||
|
|
||||||
|
apply: ignition.json $(TERRAFORM_ENV).tfvars generated.tfvars
|
||||||
|
bash -c "terraform apply -var-file=<(cat $(TERRAFORM_ENV).tfvars generated.tfvars)"
|
||||||
|
|
||||||
## to help me remember the command to run to test the config locally
|
## to help me remember the command to run to test the config locally
|
||||||
testlocalhost:
|
testlocalhost:
|
||||||
|
|||||||
40
make-generated.sh
Executable file
40
make-generated.sh
Executable file
@@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# this script generates the shared values for the
|
||||||
|
# terraform config (domain & subdomain variables)
|
||||||
|
|
||||||
|
# it depends on apps.config which should define:
|
||||||
|
# ROOT_DOMAIN - the root domain for all apps
|
||||||
|
# APP_CONFIGS - app-subdomain pairs, configured via a comma, like:
|
||||||
|
# app1,subdomain1 app2,subdomain2 app3,subdomain3
|
||||||
|
# full example:
|
||||||
|
# ROOT_DOMAIN=nassella.cc
|
||||||
|
# APP_CONFIGS="app1,subdomain1 app2,subdomain2 app3,subdomain3"
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
. apps.config
|
||||||
|
|
||||||
|
read -r -a APP_CONFIGS <<< "$APP_CONFIGS"
|
||||||
|
APP_CONFIGS+=('lb,root')
|
||||||
|
|
||||||
|
echo "domain = \"$ROOT_DOMAIN\""
|
||||||
|
echo -n "subdomains = ["
|
||||||
|
|
||||||
|
separator=''
|
||||||
|
|
||||||
|
for config_string in ${APP_CONFIGS[@]}; do
|
||||||
|
IFS=','
|
||||||
|
read -r -a config <<< "$config_string"
|
||||||
|
|
||||||
|
subdomain=${config[1]}
|
||||||
|
|
||||||
|
echo -n "$separator"
|
||||||
|
echo -n "\"$subdomain\""
|
||||||
|
|
||||||
|
separator=', '
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "]"
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user