mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Revise go setup role
- clean go cache at the role level - cache cleaning is skipped by default - fix lint errors
This commit is contained in:
committed by
Dan Christian Bogos
parent
a68880a774
commit
32e3adb9fb
@@ -6,3 +6,7 @@ go_tarball: go{{ go_version }}.{{ go_platform }}-{{ go_arch }}.tar.gz
|
||||
go_download_url: https://dl.google.com/go/{{ go_tarball }}
|
||||
go_checksum: 542d3c1705f1c6a1c5a80d5dc62e2e45171af291e755d591c5e6531ef63b454e
|
||||
install_go: true
|
||||
|
||||
# Cleaning caches assumes go is available (either installed by the role or pre-existing)
|
||||
go_clean_modcache: false
|
||||
go_clean_build_cache: false
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
- name: Check if Go is already installed.
|
||||
command: /usr/local/go/bin/go version
|
||||
ansible.builtin.command: /usr/local/go/bin/go version
|
||||
ignore_errors: true
|
||||
register: go_version_result
|
||||
changed_when: false
|
||||
|
||||
- name: Remove current installation.
|
||||
become: true
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
state: absent
|
||||
path: /usr/local/go
|
||||
when:
|
||||
@@ -17,28 +17,45 @@
|
||||
|
||||
- name: Download Go.
|
||||
become: true
|
||||
get_url:
|
||||
url: '{{ go_download_url }}'
|
||||
dest: /usr/local/src/{{ go_tarball }}
|
||||
checksum: 'sha256:{{ go_checksum }}'
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ go_download_url }}"
|
||||
dest: "/usr/local/src/{{ go_tarball }}"
|
||||
checksum: "sha256:{{ go_checksum }}"
|
||||
mode: "0644"
|
||||
when:
|
||||
- install_go | bool
|
||||
- (go_version_result is failed or go_version not in go_version_result.stdout)
|
||||
|
||||
- name: Extract Go.
|
||||
become: true
|
||||
unarchive:
|
||||
src: /usr/local/src/{{ go_tarball }}
|
||||
ansible.builtin.unarchive:
|
||||
src: "/usr/local/src/{{ go_tarball }}"
|
||||
dest: /usr/local
|
||||
copy: no
|
||||
copy: false
|
||||
when:
|
||||
- install_go | bool
|
||||
- (go_version_result is failed or go_version not in go_version_result.stdout)
|
||||
|
||||
- name: Add Go to to system-wide $PATH.
|
||||
become: true
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
dest: /etc/profile.d/go-path.sh
|
||||
content: |-
|
||||
export PATH=$PATH:/usr/local/go/bin
|
||||
mode: "0644"
|
||||
when: install_go | bool
|
||||
|
||||
# Using file module since go clean seems to only rm -rf the specified path for modcache
|
||||
- name: Clean Go modcache
|
||||
ansible.builtin.file:
|
||||
path: "{{ ansible_env.HOME }}/go/pkg/mod"
|
||||
state: absent
|
||||
when: go_clean_modcache
|
||||
|
||||
- name: Clean Go build cache
|
||||
ansible.builtin.command: go clean -x --cache
|
||||
environment:
|
||||
PATH: "{{ ansible_env.PATH }}:/usr/local/go/bin"
|
||||
register: cache_clean_result
|
||||
when: go_clean_build_cache
|
||||
changed_when: "'rm -rf' in cache_clean_result.stderr"
|
||||
|
||||
Reference in New Issue
Block a user