Skip to content
Snippets Groups Projects
Verified Commit 38b2aa46 authored by Maarten de Waard's avatar Maarten de Waard :angel:
Browse files

fix pipeline

parent 121cab21
No related branches found
No related tags found
No related merge requests found
...@@ -44,32 +44,31 @@ create-vps: ...@@ -44,32 +44,31 @@ create-vps:
then then
ip_address=$(python -m openappstack ${HOSTNAME} info --ip-address) ip_address=$(python -m openappstack ${HOSTNAME} info --ip-address)
echo "Running python script" echo "Running python script"
# Check if the cached machine still exists in the Greenhost cloud and it's # Check if the cached machine still exists in the Greenhost cloud and
# the same machine. # it's the same machine.
python3 << EOF if python3 << EOF
import greenhost_cloud import greenhost_cloud
machine = greenhost_cloud.get_droplets_by_name("^${HOSTNAME}$")[0] machine = greenhost_cloud.get_droplets_by_name("^${HOSTNAME}$")[0]
print(machine) print("Machine status is {}".format(machine['status']))
if machine['status'] == 'running' and \ print("Comparing IP address {} with IP address {}".format(machine['networks']['v4'][0]['ip_address'], '${IP_ADDRESS}'))
machine['networks']['v4'][0]['ip_address'] == '${IP_ADDRESS}': if machine['status'] != 'running' or \
exit(0) machine['networks']['v4'][0]['ip_address'] != '${IP_ADDRESS}':
else:
exit(1) exit(1)
EOF EOF;
echo "Python exited with '$?'"
# If exit code was 0, we can reuse the old machine, otherwise, continue to
# VPS creation
if [ $? -eq 0 ]
then 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
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: artifacts:
paths: paths:
- clusters - clusters
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment