Files
ansible_role_package/tasks/pkgs/go.yml
Matthew Stobbs e231c6ae7a updating documentation
- giving things a better structure
- better documentation with the way things need to be as a standard
2026-02-04 22:26:15 -07:00

97 lines
3.3 KiB
YAML

# vim: set filetype=yaml.ansible :
---
- name: Configure go for install
when:
- __go_configured is undefined
block:
- name: Configure go install method
when:
- go_install_method is undefined
ansible.builtin.set_fact:
go_install_method: "{% if install_method in go_install_methods %}{{ install_method }}{% else %}{{ go_install_methods[0] }}{% endif %}"
- name: Configure go system installation
when:
- go_install_method == 'system'
block:
- name: Set go pkgname for linux
when:
- ansible_system == 'Linux'
ansible.builtin.set_fact:
go_pkgname: "{{ go_pkgname[ansible_os_family] }}"
- name: Set go pkgname for FreeBSD
when:
- ansible_os_family == 'FreeBSD'
ansible.bulitin.set_fact:
go_pkgname: "{{ go_pkgname[ansible_os_family][go_bsd_version] | default(go_pkgname[ansible_os_family]['default']) }}"
- name: Set go pkgname for Darwin/MacOS
when:
- ansible_os_family == 'Darwin'
ansible.builtin.set_fact:
go_pkgname: "{{ go_pkgname[ansible_os_family] }}"
- name: Configure go archive installation
when:
- go_install_method == 'archive'
block:
- name: Configure go
ansible.builtin.set_fact:
go_system: "{{ ansible_system | lower }}"
- name: Set go architecture
ansible.builtin.set_fact:
go_arch: "{{ go_archmap[ansible_architecture] }}"
- name: Set archive name
ansible.builtin.set_fact:
go_archive_file: "go{{ go_archive_version }}.{{ go_system }}-{{ go_arch }}.tar.gz"
- name: Set go archive url and path
ansible.builtin.set_fact:
go_archive_url: "https://go.dev/dl/{{ go_archive_file }}"
go_extract_path: "{{ path_archive }}/go{{ go_archive_version }}"
- name: Finalize go archive install
ansible.builtin.set_fact:
go_archive_install:
extract_to: "{{ go_extract_path }}"
url: "{{ go_archive_url }}"
name: "{{ go_archive }}"
checksum: "{{ go_archive_sums[go_archive_version][ansible_system][go_arch] }}"
bins:
- from: "{{ go_archive_path }}/go"
to: "{{ path_go }}"
force: true
- from: "{{ path_go }}/bin/go"
to: "{{ path_bin }}/go"
force: true
- name: Queue go install
block:
- name: Go system package install
when:
- go_install_method == 'system'
ansible.builtin.set_fact:
pkg_sys: "{{ pkg_sys + [go_pkgname] }}"
- name: Install via archive
when:
- go_install_method == 'archive'
block:
- name: Add go archive extract install
ansible.builtin.set_fact:
pkg_archive: "{{ pkg_archive + [go_archive_install] }}"
- name: Set symbolic link to archive path
ansible.bulitin.file:
state: link
force: true
path: "{{ path_go }}"
src: "{{ go_extract_path }}/go"
- name: Complete go archive install configuration
ansible.builtin.set_fact:
__go_configured: true