diff --git a/bin/image-create-openstack.sh b/bin/image-create-openstack.sh index 1af8f93f..c89f4769 100755 --- a/bin/image-create-openstack.sh +++ b/bin/image-create-openstack.sh @@ -30,42 +30,51 @@ image_id="$(printf '%s' "$image_list" | awk -F "|" '{print $2;}' | tr -d '[:space:]')" -# If it doesn't exist then download it -if [ -z "$image_id" ]; then - echo "Image not present in OpenStack" - echo "Downloading image to local /tmp/" - curl "$KN_IMAGE_BUCKET_URL/$file_name" \ - -o "/tmp/$file_name" \ - --connect-timeout 30 \ - --max-time 1800 - - echo "Download md5 sum file" - curl "$KN_IMAGE_BUCKET_URL/$file_name.md5" \ - -o "/tmp/$file_name.md5" \ - --connect-timeout 30 \ - --max-time 1800 - - echo "Check md5 sum" - md5only=$(cut -f1 -d ' ' "/tmp/$file_name.md5") - printf '%s' "$md5only /tmp/$file_name" | md5sum -c -else - echo "File exists - no need to download" +# If it exist then exit here +if [ -n "$image_id" ]; then + echo "file exists - no need to upload, exit image-upload script" + exit 0 fi -# If it didn't exist then upload it -if [ -z "$image_id" ]; then - echo "Uploading image" - glance image-create \ - --file "/tmp/$file_name" \ - --disk-format qcow2 \ - --min-disk 20 \ - --container-format bare \ - --name "$KN_IMAGE_NAME" \ - --progress +# If it doesn't exist then download it +echo "Image not present in OpenStack" +echo "Downloading image to local /tmp/" +curl "$KN_IMAGE_BUCKET_URL/$file_name" \ + -o "/tmp/$file_name" \ + --connect-timeout 30 \ + --max-time 1800 + +echo "Download md5 sum file" +curl "$KN_IMAGE_BUCKET_URL/$file_name.md5" \ + -o "/tmp/$file_name.md5" \ + --connect-timeout 30 \ + --max-time 1800 + +# Verify md5sum of downloaded file +echo "Check md5 sum" +md5result=$( + cd /tmp + md5sum -c "$file_name.md5" +) +if [[ "$md5result" != *": OK"* ]]; then + echo >&2 "Wrong checksum of downloaded image." + echo >&2 "Something might have failed on file transfer." + echo >&2 "Please try again." + exit 1 else - echo "file exists - no need to upload" + echo "Checksum of downloaded image OK" fi +# Upload image +echo "Uploading image" +glance image-create \ + --file "/tmp/$file_name" \ + --disk-format qcow2 \ + --min-disk 20 \ + --container-format bare \ + --name "$KN_IMAGE_NAME" \ + --progress + echo "Verify md5 of present/uploaded image..." echo "List images available in OpenStack..." image_list="$(glance image-list)" diff --git a/playbooks/roles/traefik-test/tasks/test-page.yml b/playbooks/roles/traefik-test/tasks/test-page.yml index 7a94385c..bd6c1762 100644 --- a/playbooks/roles/traefik-test/tasks/test-page.yml +++ b/playbooks/roles/traefik-test/tasks/test-page.yml @@ -1,5 +1,5 @@ --- -- name: "test endpoint" +- name: "test endpoint: http://{{cheese}}.{{cheese_domain_name}}" command: > curl --silent --head -H "host: {{cheese}}.{{cheese_domain_name}}" @@ -9,7 +9,7 @@ retries: 5 delay: 30 -- name: "test page" +- name: "test page: http://{{cheese}}.{{cheese_domain_name}}" action: > uri url=http://{{cheese}}.{{cheese_domain_name}} diff --git a/templates/terraform.tfvars.azure-template b/templates/terraform.tfvars.azure-template index a9dbcc99..99822a40 100644 --- a/templates/terraform.tfvars.azure-template +++ b/templates/terraform.tfvars.azure-template @@ -33,6 +33,7 @@ node_vm_size = "Standard_DS2_v2" # cloudflare_email = "your-cloudflare-email" # cloudflare_token = "your-cloudflare-token" # cloudflare_domain = "your-domain-name" +# cloudflare_subdomain = "your-subdomain-name" # Cloudflare proxy (optional) # cloudflare_proxied = "true"