- name: Register the current Go version (if any) command: go version ignore_errors: yes register: go_version changed_when: false - name: Download the Go tarball get_url: url: "https://go.dev/dl/{{ go_tarball }}" dest: /usr/local/src/{{ go_tarball }} checksum: "{{ go_checksum }}" #when: go_version|failed or go_version.stdout != go_version_target - 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 #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 copy: src: go-bin.sh dest: /etc/profile.d - name: Set GOPATH for all users copy: src: go-path.sh dest: /etc/profile.d #when: set_go_path