diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e7104a28fd8cae5f447700ad2cac7b85e02c0ad7..4943826317b81a95dee97c8fa6c9c798304691a7 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -44,32 +44,31 @@ create-vps:
       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
+        # Check if the cached machine still exists in the Greenhost cloud and
+        # it's the same machine.
+        if 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)
-      else:
+      print("Machine status is {}".format(machine['status']))
+      print("Comparing IP address {} with IP address {}".format(machine['networks']['v4'][0]['ip_address'], '${IP_ADDRESS}'))
+      if machine['status'] != 'running' or \
+              machine['networks']['v4'][0]['ip_address'] != '${IP_ADDRESS}':
           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 ]
+      EOF;
         then
-          exit 0
+          # 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 \
+            --acme-staging \
+            --create-droplet $DOMAIN \
+            --create-hostname $HOSTNAME \
+            --ssh-key-id $SSH_KEY_ID \
+            --create-domain-records \
+            --subdomain $SUBDOMAIN
         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 --acme-staging --create-droplet $DOMAIN --create-hostname $HOSTNAME --ssh-key-id $SSH_KEY_ID --create-domain-records --subdomain $SUBDOMAIN
   artifacts:
     paths:
     - clusters