diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b902a0e4fa480f55fc52f2b9b1dfc223016efd3a..c8ea7aed9c5c5cc8fa0253f7f8bad4f887e8b6a5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -43,11 +43,13 @@ create-vps: if [ -d clusters/$HOSTNAME/secrets ] then ip_address=$(python -m openappstack ${HOSTNAME} info --ip-address) + echo "Running python script" # Check if the cached machine still exists in the Greenhost cloud and it's # the same machine. python3 << EOF import greenhost_cloud machine = greenhost_cloud.get_droplets_by_name("^${HOSTNAME}$")[0] + print(machine) if machine['status'] == 'running' and \ machine['networks']['v4'][0]['ip_address'] == '${IP_ADDRESS}': exit(0) @@ -55,6 +57,7 @@ create-vps: exit(1) EOF + echo "Python exited with '$?'" # If exit code was 0, we can reuse the old machine, otherwise, continue to # VPS creation if [ $? -eq 0 ] @@ -63,7 +66,9 @@ create-vps: fi fi # Delete old machine if it still exists + echo "Deleting old machine" python3 -c "import greenhost_cloud; greenhost_cloud.terminate_droplets_by_name(\"^${HOSTNAME}$\")" + echo "Creating new machine" python3 -m openappstack $HOSTNAME create --create-droplet $DOMAIN --create-hostname $HOSTNAME --ssh-key-id $SSH_KEY_ID --create-domain-records --subdomain $SUBDOMAIN artifacts: paths: