aboutsummaryrefslogtreecommitdiff
path: root/deploy.sh
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-12-30 19:27:32 +0100
committerAlex Auvolat <alex@adnab.me>2021-12-30 19:27:32 +0100
commitb00a8358b20ac99912bacafd8fee5466da257e67 (patch)
treedf81c06567cbae31098ac77f41c9c11d67b9cc79 /deploy.sh
parent230c1d727b951e032603a5c776f540003829bff6 (diff)
downloadnixcfg-b00a8358b20ac99912bacafd8fee5466da257e67.tar.gz
nixcfg-b00a8358b20ac99912bacafd8fee5466da257e67.zip
Add TLS to Nomad
Diffstat (limited to 'deploy.sh')
-rwxr-xr-xdeploy.sh13
1 files changed, 11 insertions, 2 deletions
diff --git a/deploy.sh b/deploy.sh
index 4d6387f..a4f18c1 100755
--- a/deploy.sh
+++ b/deploy.sh
@@ -10,6 +10,8 @@ fi
TMP_PATH=/tmp/tmp-deploy-$(date +%s)
+YEAR=$(date +%Y)
+
for NIXHOST in $NIXHOSTLIST; do
NIXHOST=${NIXHOST%.*}
@@ -23,13 +25,15 @@ for NIXHOST in $NIXHOSTLIST; do
echo "Sending NixOS config files"
- ssh -F ssh_config $SSH_DEST mkdir -p $TMP_PATH
+ ssh -F ssh_config $SSH_DEST mkdir -p $TMP_PATH $TMP_PATH/pki
cat configuration.nix | ssh -F ssh_config $SSH_DEST tee $TMP_PATH/configuration.nix > /dev/null
cat node/$NIXHOST.nix | ssh -F ssh_config $SSH_DEST tee $TMP_PATH/node.nix > /dev/null
cat node/$NIXHOST.site.nix | ssh -F ssh_config $SSH_DEST tee $TMP_PATH/site.nix > /dev/null
echo "Sending secret files"
- test -f secrets/rclone.conf && (cat secrets/rclone.conf | ssh -F ssh_config $SSH_DEST tee $TMP_PATH/rclone.conf > /dev/null)
+ for SECRET in rclone.conf pki/nomad-ca.crt pki/nomad$YEAR.crt pki/nomad$YEAR.key; do
+ test -f secrets/$SECRET && (cat secrets/$SECRET | ssh -F ssh_config $SSH_DEST tee $TMP_PATH/$SECRET > /dev/null)
+ done
echo "Rebuilding NixOS"
@@ -38,7 +42,12 @@ set -ex
cd $TMP_PATH
mv configuration.nix node.nix site.nix /etc/nixos
+
test -f rclone.conf && (mv rclone.conf /root; chmod 600 /root/rclone.conf)
+
+mkdir -p /var/lib/nomad/pki
+test -f pki/nomad-ca.crt && mv -v pki/nomad* /var/lib/nomad/pki
+
nixos-rebuild switch
EOF