Files
ansible_role_package/tasks/archive/go.yml
2025-05-16 16:29:56 -06:00

62 lines
1.6 KiB
YAML

# vim: set filetype=yaml.ansible :
---
- name: Check if go is already installed
ansible.builtin.stat:
path: "{{ path.go }}/VERSION"
register: stat_path_go
- name: Check installed go version
when:
- stat_path_go.stat.exists
block:
- name: Get installed version
register: r_go_version
ansible.builtin.command:
argv:
- "{{ path.go }}/bin/go"
- version
- name: Check if go needs updating
when:
- r_go_version.rc|int == 0
ansible.builtin.set_fact:
go_do_update: "{{ go.vers in r_go_version.stdout }}"
- name: Install/update go
when:
- not stat_path_go.stat.exists or
go_do_update
block:
- name: Remove existing go install
when:
- ansible_system == 'Linux'
become: "{{ ext_become }}"
ansible.builtin.file:
state: absent
path: "{{ path.go }}"
- name: Download go archive
register: get_url_go
ansible.builtin.get_url:
dest: "{{ d_tempdir.path }}/{{ go.archive }}"
url: "{{ go.base_url }}/{{ go.archive }}"
checksum: "{{ go.sum }}"
decompress: false
mode: '0644'
- name: Extract go package for Linux
become: "{{ ext_become }}"
when:
- ansible_system == 'Linux'
ansible.builtin.unarchive:
dest: "{{ go.prefix }}"
src: "{{ d_tempdir.path }}/{{ go.archive }}"
remote_src: true
- name: Install go macOS using pkg file
become: true
when:
- ansible_distribution == 'MacOSX'
ansible.builtin.command:
cmd: "installer -pkg {{ d_tempdir.path }}/{{ go.archive }} -target {{ go.prefix }}"