summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2018-12-05 10:18:49 -0500
committerJesse Luehrs <doy@tozt.net>2018-12-05 10:18:49 -0500
commit2ed8df07c42642f6f825e6ef2d94b894450e0b1e (patch)
tree90f4fc7260bd5722ff9fe0fe5e11946c2f1adceb /bin
parent66b45bd68a00ff7e68e854731659c7d9b6c49cd1 (diff)
downloadpuppet-tozt-2ed8df07c42642f6f825e6ef2d94b894450e0b1e.tar.gz
puppet-tozt-2ed8df07c42642f6f825e6ef2d94b894450e0b1e.zip
add a base configuration for testing the d2a script
Diffstat (limited to 'bin')
-rwxr-xr-xbin/helpers/launch-base58
-rwxr-xr-xbin/launch2
-rwxr-xr-xbin/terminate2
3 files changed, 60 insertions, 2 deletions
diff --git a/bin/helpers/launch-base b/bin/helpers/launch-base
new file mode 100755
index 0000000..c70bcac
--- /dev/null
+++ b/bin/helpers/launch-base
@@ -0,0 +1,58 @@
+#!/usr/bin/env bash
+set -eu
+set -o pipefail
+
+echo "Creating droplet for base..."
+data=$(doctl \
+ -t "$(cat /mnt/digitalocean)" \
+ compute droplet create \
+ base \
+ --image debian-9-x64 \
+ --region nyc3 \
+ --size s-1vcpu-1gb \
+ --ssh-keys 23160354 \
+ --format ID,PublicIPv4 \
+ --no-header \
+ --wait)
+id=$(echo "$data" | awk '{print $1}')
+ip=$(echo "$data" | awk '{print $2}')
+echo "Created droplet with id $id and ip $ip"
+
+echo "Provisioning droplet..."
+
+conf_location="/usr/local/share/puppet-tozt"
+conf_repo="git://github.com/doy/puppet-tozt"
+
+remote() {
+ # shellcheck disable=SC2029
+ ssh -oStrictHostKeyChecking=accept-new root@"$ip" "$@"
+}
+
+ensure_conf_exists() {
+ if remote test -d "$conf_location"; then
+ remote "cd '$conf_location' && git pull"
+ else
+ remote "mkdir -p '$conf_location'"
+ remote "cd '$conf_location' && git clone '$conf_repo' ."
+ fi
+ remote "cd '$conf_location' && git submodule update --init --recursive"
+}
+
+while ! remote true; do
+ sleep 5
+done
+
+if remote test ! -e /usr/bin/pacman; then
+ remote apt-get -y update
+ remote apt-get -y install git
+ ensure_conf_exists
+ remote "cd '$conf_location/digitalocean-debian-to-arch' && bash install.sh --i_understand_that_this_droplet_will_be_completely_wiped --extra_packages 'puppet git ruby-shadow'"
+ sleep 30
+ while ! remote true; do
+ sleep 30
+ done
+fi
+
+ensure_conf_exists
+
+echo "Done provisioning"
diff --git a/bin/launch b/bin/launch
index 663b176..5ae25a4 100755
--- a/bin/launch
+++ b/bin/launch
@@ -6,7 +6,7 @@ script_path="$(realpath "$(dirname "$0")")"
secrets_bin="${script_path}/secrets"
case "$1" in
- tozt|algo|mail|partofme)
+ base|tozt|algo|mail|partofme)
"$secrets_bin" open
trap '"$secrets_bin" close' EXIT
"$(dirname "$0")/helpers/launch-$1"
diff --git a/bin/terminate b/bin/terminate
index 5c99407..2b100c1 100755
--- a/bin/terminate
+++ b/bin/terminate
@@ -6,7 +6,7 @@ script_path="$(realpath "$(dirname "$0")")"
secrets_bin="${script_path}/secrets"
case "$1" in
- tozt|algo|mail|partofme)
+ base|tozt|algo|mail|partofme)
"$secrets_bin" open
trap '"$secrets_bin" close' EXIT
doctl -t "$(cat /mnt/digitalocean)" compute droplet delete "$1"