This golang roles installs Go into the user’s home directory. It is quite opinionated in how it works it it makes installing and switching Go versions rather easy. Usage from within a task set:
- name: install with role
include_role:
name: sascha_andres.ansible_role_golang
vars:
go_ver: 1.12.1
There are two other variables to pass. go_platform which defaults to linux_amd64 and is unlikely to be changed and go_parent_dir. Go parent dir is a sub directory of the home directory for the user. Versions of go will be placed there and a link current pointing to the version you want will be created there also.
The role does no set any environment variables. With the adoption of go modules need to set GOPATH should be reduced in the future.
The go_parent_dir variable may change from being relative to absolute in the future.
You can see the code here and install from ansible galaxy.