Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workaround failure of get_url on python 2.7.6 hosts #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions files/resolve-redirect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
PYTHON_VERSION=$1
URL=$2

# golang URLs are behind a redirect that requires clients
# that support TLS SNI which Python 2.7.6 found on
# most Ubuntu 14.04 installations does not support.
# get_url will fail if executed against the original URL
# but will succeed with the final URL

test "$PYTHON_VERSION" "<" "2.7.9" &&
url=$(curl -s -I "$URL" | sed -n "s/Location: //p") &&
test -n "$url" &&
URL="$url"; echo "$URL"
6 changes: 5 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
---
- name: Resolve redirect early for Python < 2.7.9
script: files/resolve-redirect.sh {{ ansible_python_version }} {{ go_download_location }}
register: go_download_location_adjusted

- name: Download the Go tarball
get_url: url={{ go_download_location }}
get_url: url={{ go_download_location_adjusted.stdout }}
dest=/usr/local/src/{{ go_tarball }}
sha256sum={{ go_tarball_checksum }}

Expand Down
2 changes: 1 addition & 1 deletion vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
go_download_location: "https://storage.googleapis.com/golang/{{ go_tarball }}"
go_download_location: "https://golang.org/dl/{{ go_tarball }}"