Files
ansible_role_package/tasks/pkgs/go.yml
Matthew Stobbs 01239701f9 add restic
- fix packages that were broken
- change the way configuration is done
  - define default facts for packages with os_family level vars
  - refine the default facts into an os_family specfic config
2026-04-18 18:44:18 -06:00

125 lines
4.6 KiB
YAML

# vim: set filetype=yaml.ansible :
#
## Package: go
## Description: go compiler and module manager
## Version: 1.26.1
---
- name: Set go default facts # {{{
ansible.builtin.set_fact:
go:
methods:
- archive
- system
pkgname:
RedHat: go
Debian: go
Darwin: go
Archlinux: go
FreeBSD:
default: go
1.26: go126
1.25: go125
1.24: go124
1.23: go123
1.22: go122
archive:
version: "{{ go_archive_version | default('1.26.1') }}"
archmap:
arm64: arm64
aarch64: arm64
x86_64: amd64
url_base: https://go.dev/dl
checksums:
1.26.1:
Darwin:
amd64: sha256:65773dab2f8cc4cd23d93ba6d0a805de150ca0b78378879292be0b903b8cdd08
arm64: sha256:353df43a7811ce284c8938b5f3c7df40b7bfb6f56cb165b150bc40b5e2dd541f
Linux:
amd64: sha256:031f088e5d955bab8657ede27ad4e3bc5b7c1ba281f05f245bcc304f327c987a
arm64: sha256:a290581cfe4fe28ddd737dde3095f3dbeb7f2e4065cab4eae44dfc53b760c2f7
FreeBSD:
amd64: sha256:d89034a0b54fdc234815fecfb76d7d06a7d180d7a6124aa47715a4cacc9fe999
arm64: sha256:d62b358dbf7bcfc33402e7e221d848e7fd8d7ac902b33920f2c23c8a32ba76db
1.25.6:
Darwin:
amd64: sha256:e2b5b237f5c262931b8e280ac4b8363f156e19bfad5270c099998932819670b7
arm64: sha256:984521ae978a5377c7d782fd2dd953291840d7d3d0bd95781a1f32f16d94a006
Linux:
amd64: sha256:f022b6aad78e362bcba9b0b94d09ad58c5a70c6ba3b7582905fababf5fe0181a
arm64: sha256:738ef87d79c34272424ccdf83302b7b0300b8b096ed443896089306117943dd5
FreeBSD:
amd64: sha256:61e1d50e332359474ff6dcf4bc0bd34ba2d2cf4ef649593a5faa527f0ab84e2b
arm64: sha256:648484146702dd58db0e2c3d15bda3560340d149ed574936e63285a823116b77
# }}}
- name: Configure go for install
when:
- "'go' not in __configured"
block:
- name: Configure go install method
when:
- go_imethod is undefined
ansible.builtin.set_fact:
go_imethod: "{{ imethod if imethod in go.methods else go.methods[0] }}"
- name: Configure go system installation
when:
- go_imethod == 'system'
block:
- name: Set go pkgname
ansible.builtin.set_fact:
go_pkgname: "{{ go.pkgname[os_family] }}"
- name: Set go pkgname for FreeBSD
when:
- ansible_os_family == 'FreeBSD'
ansible.builtin.set_fact:
go_pkgname: "{{ go_pkgname[go_bsd_version] | default(go_pkgname['default']) }}"
- name: Go system package install
ansible.builtin.set_fact:
pkg_sys: "{{ pkg_sys + [go_pkgname] }}"
go_install: "{{ go_imethod }}={{ go_pkgname }}"
- name: Configure go archive installation
when:
- go_imethod == 'archive'
block:
- name: Configure go
ansible.builtin.set_fact:
go_system: "{{ ansible_system | lower }}"
go_arch: "{{ go.archive.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: "{{ go.archive.url_base }}/{{ 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_file }}"
checksum: "{{ go.archive.checksums[go.archive.version][ansible_system][go_arch] }}"
links:
- from: "{{ go_extract_path }}/go"
to: "{{ path_go }}"
force: true
- from: "{{ go_extract_path }}/go/bin/go"
to: "{{ path_bin }}/go"
force: true
__add_to_path: "{{ __add_to_path + [path_go ~ '/bin'] }}"
__var_to_env: "{{ __var_to_env | combine( { 'GOROOT': path_go } ) }}"
- name: Add go archive extract install
ansible.builtin.set_fact:
pkg_archive: "{{ pkg_archive + [go_archive_install] }}"
- name: Finalise go configuration
ansible.builtin.set_fact:
__configured: "{{ __configured | combine( { 'go': go_imethod } ) }}"