Files
ansible_role_package/tasks/archive/go.yml
2025-02-21 22:59:24 -07:00

45 lines
1.3 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 version of installed go
when:
- stat_path_go.stat.exists
ansible.builtin.set_fact:
do_go_install: "{{ not (go.vers in lookup('ansible.builtin.file', path.go ~ '/VERSION')) }}"
- name: Install/update go
when:
- do_go_install or
not stat_path_go.stat.exists
block:
- name: Download go archive
become: "{{ sys_pkg_become }}"
register: get_url_go
ansible.builtin.get_url:
dest: "{{ path.cache }}/{{ go.archive }}"
url: "{{ go.url }}"
checksum: "{{ go.sum }}"
decompress: false
mode: '0644'
- name: Extract go package for Linux
become: "{{ ext_become }}"
when:
- ansible_system == 'Linux'
ansible.builtin.unarchive:
dest: "{{ path.prefix }}"
src: "{{ d_go_dl_tmp.path }}/{{ go.archive }}"
remote_src: true
- name: Install go macOS using pkg file
become: true
when:
- ansible_distribution == 'MacOSX'
ansible.builtin.command:
creates: "{{ path.go }}"
cmd: "installer -pkg {{ d_go_dl_tmp.path }}/{{ go.archive }} -target /"