Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
smatting committed Sep 30, 2024
1 parent 35323ca commit b51cfe9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 20 deletions.
8 changes: 4 additions & 4 deletions ansible/hetzner-single-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
- hosts: all
become: true
vars:
artifact_hash: d8fe36747614968ea73ebd43d47b99364c52f9c1
ubuntu_version: 22.04.4
ssh_pubkey: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDPTGTo1lTqd3Ym/75MRyQvj8xZINO/GI6FzfIadSe5c [email protected]"
artifact_hash: dd7b682ba14c65116fa9a87b1dc80787bbad16bb
ubuntu_version: 22.04.5
ssh_pubkey: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBantLLGJX/7S6zT+ixyNdQ81XSboOkErYo7Bi9tUIwX"
tasks:
- name: set ipv4 forward
sysctl:
Expand Down Expand Up @@ -40,7 +40,7 @@
- docker.io
- telnet
- python3-lxml
- qemu
- qemu-system-x86
- qemu-kvm
- qemu-utils
- libvirt-clients
Expand Down
1 change: 1 addition & 0 deletions ansible/inventory.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
webapp.wiab-autodeploy.wire.link
41 changes: 26 additions & 15 deletions bin/autodeploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
# shellcheck disable=SC2087
set -Eeuo pipefail


#
# Problems discovered while running this script
#
# - on first run "virsh" not found. This seems to be installed only later
# - change cleanup user logic:
#
#
#

msg() {
echo >&2 -e "${1-}"
}
Expand All @@ -28,7 +38,7 @@ Running the script without any arguments requires one interaction - confirming t
For CI usage, it's recommended to invoke "--force-redeploy".
It is likely desirable to invoke the script with "--artifact-hash" and / or "--target-domain" as well. These are the hardcoded fallback values:
* artifact-hash = 5c06158547bc57846eadaa2be5c813ec43be9b59
* artifact-hash = dd7b682ba14c65116fa9a87b1dc80787bbad16bb
* target-domain = wiab-autodeploy.wire.link
Available options:
Expand Down Expand Up @@ -78,7 +88,7 @@ parse_params() {

parse_params "$@"

ARTIFACT_HASH="${ARTIFACT_HASH:-5c06158547bc57846eadaa2be5c813ec43be9b59}"
ARTIFACT_HASH="${ARTIFACT_HASH:-dd7b682ba14c65116fa9a87b1dc80787bbad16bb}"
TARGET_SYSTEM="${TARGET_SYSTEM:-wiab-autodeploy.wire.link}"
FORCE_REDEPLOY="${FORCE_REDEPLOY:-0}"
SUBDOMAINS="account assets coturn federator inbucket nginz-https nginz-ssl sft teams webapp"
Expand All @@ -104,14 +114,14 @@ if ssh -q -o ConnectTimeout=5 -p "$SSH_PORT" "$SSH_USER"@webapp."$TARGET_SYSTEM"
msg ""
msg "INFO: Successfully logged into $TARGET_SYSTEM as $SSH_USER"
else
die "ERROR: Can't log into $TARGET_SYSTEM via SSH, please check SSH connectivity."
die "ERROR: Can't log into webapp.$TARGET_SYSTEM via SSH, please check SSH connectivity."
fi

if curl --head --silent --fail https://s3-eu-west-1.amazonaws.com/public.wire.com/artifacts/wire-server-deploy-static-"$ARTIFACT_HASH".tgz >/dev/null 2>&1 ; then
msg "INFO: Artifact exists https://s3-eu-west-1.amazonaws.com/public.wire.com/artifacts/wire-server-deploy-static-$ARTIFACT_HASH.tgz"
else
die "ERROR: No artifact found via https://s3-eu-west-1.amazonaws.com/public.wire.com/artifacts/wire-server-deploy-static-$ARTIFACT_HASH.tgz"
fi
# if curl --head --silent --fail https://s3-eu-west-1.amazonaws.com/public.wire.com/artifacts/wire-server-deploy-static-"$ARTIFACT_HASH".tgz >/dev/null 2>&1 ; then
# msg "INFO: Artifact exists https://s3-eu-west-1.amazonaws.com/public.wire.com/artifacts/wire-server-deploy-static-$ARTIFACT_HASH.tgz"
# else
# die "ERROR: No artifact found via https://s3-eu-west-1.amazonaws.com/public.wire.com/artifacts/wire-server-deploy-static-$ARTIFACT_HASH.tgz"
# fi

system_cleanup_meta() {
msg ""
Expand All @@ -126,12 +136,14 @@ system_cleanup
EOT
}

# TODO:: Check if virsh is available. If not (fresh install) then you don't need to check
# for
system_cleanup() {
for VM in $(virsh list --all --name); do virsh destroy "$VM"; virsh undefine "$VM" --remove-all-storage; done
docker system prune -a -f
rm -f /home/$DEMO_USER/.ssh/known_hosts
rm -rf /home/$DEMO_USER/wire-server-deploy
rm -f /home/$DEMO_USER/wire-server-deploy-static-*.tgz
# docker system prune -a -f
# rm -f /home/$DEMO_USER/.ssh/known_hosts
# rm -rf /home/$DEMO_USER/wire-server-deploy
# rm -f /home/$DEMO_USER/wire-server-deploy-static-*.tgz
}

preprovision_hetzner() {
Expand Down Expand Up @@ -170,8 +182,7 @@ remote_deployment() {
ZAUTH_CONTAINER=$(sudo docker load -i "$SCRIPT_DIR"/containers-adminhost/quay.io_wire_zauth_*.tar | awk '{print $3}')
export ZAUTH_CONTAINER
WSD_CONTAINER=$(sudo docker load -i "$SCRIPT_DIR"/containers-adminhost/container-wire-server-deploy.tgz | awk '{print $3}')
d() {
sudo docker run --network=host -v "${SSH_AUTH_SOCK:-nonexistent}":/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent -v "$HOME"/.ssh:/root/.ssh -v "$PWD":/wire-server-deploy "$WSD_CONTAINER" "$@"
d() { sudo docker run --network=host -v "${SSH_AUTH_SOCK:-nonexistent}":/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent -v "$HOME"/.ssh:/root/.ssh -v "$PWD":/wire-server-deploy "$WSD_CONTAINER" "$@"
}
export -f d

Expand Down Expand Up @@ -405,7 +416,7 @@ if [ "$DO_SYSTEM_CLEANUP" = true ] && [ "$FORCE_REDEPLOY" = 1 ]; then
fi

msg "INFO: Commencing Wire-in-a-box deployment on $TARGET_SYSTEM."
preprovision_hetzner
# preprovision_hetzner
ssh -p "$SSH_PORT" "$DEMO_USER"@webapp."$TARGET_SYSTEM" "bash -s" <<EOT
# Making relevant vars and functions available to remote shell via SSH
$(declare -p DEMO_USER TARGET_SYSTEM SCRIPT_DIR)
Expand Down
2 changes: 1 addition & 1 deletion bin/offline-vm-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ else
VM_IP=(192.168.122.10 192.168.122.21 192.168.122.22 192.168.122.23 192.168.122.31 192.168.122.32 192.168.122.33)
VM_VCPU=(2 6 6 6 4 4 4)
VM_RAM=(4096 8192 8192 8192 8192 8192 8192)
VM_DISK=(100 100 100 100 350 350 350)
VM_DISK=(100 100 100 100 100 100 100)
fi

if [[ -f "$HOME"/.ssh/authorized_keys && -s "$HOME"/.ssh/authorized_keys ]]; then
Expand Down

0 comments on commit b51cfe9

Please sign in to comment.