zuul-jobs/roles/install-go/tasks/main.yaml
vass 0ee411860a Adds go jobs and roles.
Adds jobs to test and build go packages.
Adds a role to download and install go from
the official download page (https://golang.org/dl/).
Adds a role to run commands with go e.g build, test, run.

Change-Id: Iad2d877fffa2530e9fdeec648a60755a80cf01f4
2019-11-20 20:27:21 +01:00

40 lines
1.3 KiB
YAML

- name: Check installed go version
command: go version
register: go_installed_version
environment:
PATH: "{{ ansible_env.PATH }}:{{ go_install_dir }}/go/bin"
ignore_errors: yes
- name: Skip if correct version of go is installed
meta: end_host
when:
- go_installed_version.rc == 0
- go_version == (go_installed_version.stdout|regex_replace(go_version_pattern, '\\g<version>'))
- go_os == (go_installed_version.stdout|regex_replace(go_version_pattern, '\\g<os>'))
- go_arch == (go_installed_version.stdout|regex_replace(go_version_pattern, '\\g<arch>'))
- name: Create temp directory
tempfile:
state: directory
register: go_archive_tempdir
- name: Get archive checksum
uri:
url: "https://dl.google.com/go/go{{ go_version }}.{{ go_os }}-{{ go_arch }}.tar.gz.sha256"
return_content: true
register: go_archive_checksum
- name: Download go archive
get_url:
url: "https://dl.google.com/go/go{{ go_version }}.{{ go_os }}-{{ go_arch }}.tar.gz"
dest: "{{ go_archive_tempdir.path }}/go{{ go_version }}.{{ go_os }}-{{ go_arch }}.tar.gz"
checksum: "sha256:{{ go_archive_checksum.content }}"
- name: Install go
unarchive:
src: "{{ go_archive_tempdir.path }}/go{{ go_version }}.{{ go_os }}-{{ go_arch }}.tar.gz"
dest: "{{ go_install_dir }}"
remote_src: yes
become: true