diff --git a/prepare-vms/infra/scaleway b/prepare-vms/infra/scaleway new file mode 100644 index 00000000..7615e024 --- /dev/null +++ b/prepare-vms/infra/scaleway @@ -0,0 +1,5 @@ +INFRACLASS=scaleway +if ! [ -f ~/.config/scw/config.yaml ]; then + warn "~/.config/scw/config.yaml not found." + warn "Make sure that the scaleway CLI is installed and configured." +fi diff --git a/prepare-vms/lib/commands.sh b/prepare-vms/lib/commands.sh index 0918b101..5c0cc631 100644 --- a/prepare-vms/lib/commands.sh +++ b/prepare-vms/lib/commands.sh @@ -65,6 +65,14 @@ _cmd_deploy() { sleep 1 done" + # Special case for scaleway since it doesn't come with sudo + if [ "$INFRACLASS" = "scaleway" ]; then + pssh -l root " + grep DEBIAN_FRONTEND /etc/environment || echo DEBIAN_FRONTEND=noninteractive >> /etc/environment + grep cloud-init /etc/sudoers && rm /etc/sudoers + apt-get update && apt-get install sudo -y" + fi + # Copy settings and install Python YAML parser pssh -I tee /tmp/settings.yaml tags/$TAG/ips.txt +} + +infra_stop() { + for ID in $(scw_get_ids_by_tag $TAG); do + info "Scheduling deletion of instance $ID..." + scw instance server delete force-shutdown=true server-id=$ID & + done + info "Waiting for deletion to complete..." + wait +} + +scw_get_ids_by_tag() { + TAG=$1 + scw instance server list name=$TAG -o json | jq -r .[].id +} + +scw_get_ips_by_tag() { + TAG=$1 + scw instance server list name=$TAG -o json | jq -r .[].public_ip.address +} + +infra_opensg() { + die "unimplemented" +} + +infra_disableaddrchecks() { + die "unimplemented" +}