From 21ad5850327d3b055f9e3dea012792fb949a4bb6 Mon Sep 17 00:00:00 2001 From: brad Date: Sat, 15 Sep 2018 00:37:50 -0500 Subject: [PATCH] avoid unnecessary tarball downloading --- tasks/install.yml | 18 ++++++++++++++++++ tasks/main.yml | 17 +---------------- 2 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 tasks/install.yml diff --git a/tasks/install.yml b/tasks/install.yml new file mode 100644 index 0000000..410c039 --- /dev/null +++ b/tasks/install.yml @@ -0,0 +1,18 @@ +--- + +- name: Download the Go tarball + get_url: + url: "{{ go_download_location }}" + dest: /usr/local/src/{{ go_tarball }} + checksum: "{{ go_tarball_checksum }}" + +- name: Remove old installation of Go + file: + path: /usr/local/go + state: absent + +- name: Extract the Go tarball if Go is not yet installed or not the desired version + unarchive: + src: /usr/local/src/{{ go_tarball }} + dest: /usr/local + copy: no \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index 72f63d3..3a856c2 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,9 +1,4 @@ --- -- name: Download the Go tarball - get_url: - url: "{{ go_download_location }}" - dest: /usr/local/src/{{ go_tarball }} - checksum: "{{ go_tarball_checksum }}" - name: Register the current Go version (if any) command: /usr/local/go/bin/go version @@ -11,17 +6,7 @@ register: go_version changed_when: false -- name: Remove old installation of Go - file: - path: /usr/local/go - state: absent - when: go_version|failed or go_version.stdout != go_version_target - -- name: Extract the Go tarball if Go is not yet installed or not the desired version - unarchive: - src: /usr/local/src/{{ go_tarball }} - dest: /usr/local - copy: no +- include: install.yml when: go_version|failed or go_version.stdout != go_version_target - name: Add the Go bin directory to the PATH environment variable for all users