Skip to content

Commit 162f1ad

Browse files
committed
P:puppet: add decom instance script
1 parent 6f6ef47 commit 162f1ad

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
# Removes an instance
3+
4+
set -euo pipefail
5+
. /etc/jq-tarsnap-keygen.sh
6+
7+
INSTANCE="$1"
8+
9+
TARNSAP_KEYFILE="$TARSNAP_KEYS_BASE_PATH/$INSTANCE.key"
10+
11+
echo "=== Cleaning up $INSTANCE"
12+
13+
if [ -f "$TARNSAP_KEYFILE" ]; then
14+
echo "Cleaning up old Tarsnap backups and key file"
15+
if ! git -C "$TARSNAP_KEYS_BASE_PATH" diff-index --quiet HEAD --; then
16+
echo "The private git directory has uncommitted changes, please fix that before running this script."
17+
exit 1
18+
fi
19+
20+
tarsnap --keyfile "$TARNSAP_KEYFILE" --nuke
21+
22+
git -C "$TARSNAP_KEYS_BASE_PATH" rm "$KEYFILE"
23+
git -C "$TARSNAP_KEYS_BASE_PATH" commit -m "remove Tarsnap keys for $INSTANCE"
24+
fi
25+
26+
echo "Removing from Puppet"
27+
28+
sudo puppet node deactivate "$INSTANCE"
29+
sudo puppet node clean "$INSTANCE"
30+
31+
echo "=== All done."

modules/profile/manifests/puppet/server.pp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,16 @@
187187
paths => [$private_repo_dir],
188188
}
189189

190+
# This also uses config from tarsnap::keymgmt.
191+
file { '/usr/local/bin/jq-decom-instance':
192+
ensure => file,
193+
source => 'puppet:///modules/profile/puppet/server/jq-decom-instance.sh',
194+
owner => 'root',
195+
group => 'gitpuppet',
196+
mode => '0550',
197+
}
198+
199+
190200
include profile::ssh::ca
191201

192202
# Expose SSH keys so users can verify them

0 commit comments

Comments
 (0)