mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-21 23:28:44 +05:00
Revise go setup role and bump version
- clean go cache at the role level - use go env GOMODCACHE for path resolution - add become: true to prevent permission issues - check stdout instead of stderr for go clean -x --cache - cache cleaning is skipped by default - fix lint errors
This commit is contained in:
committed by
Dan Christian Bogos
parent
3545224ee6
commit
1c672c33ec
@@ -1,8 +1,12 @@
|
||||
---
|
||||
go_version: 1.23.1
|
||||
go_version: 1.24.0
|
||||
go_platform: linux
|
||||
go_arch: amd64
|
||||
go_tarball: go{{ go_version }}.{{ go_platform }}-{{ go_arch }}.tar.gz
|
||||
go_download_url: https://dl.google.com/go/{{ go_tarball }}
|
||||
go_checksum: 49bbb517cfa9eee677e1e7897f7cf9cfdbcf49e05f61984a2789136de359f9bd
|
||||
go_checksum: dea9ca38a0b852a74e81c26134671af7c0fbe65d81b0dc1c5bfe22cf7d4c8858
|
||||
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,54 @@
|
||||
|
||||
- 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
|
||||
|
||||
- name: Get Go modcache path
|
||||
ansible.builtin.command: go env GOMODCACHE
|
||||
environment:
|
||||
PATH: "{{ ansible_env.PATH }}:/usr/local/go/bin"
|
||||
register: gomodcache_path
|
||||
changed_when: false
|
||||
when: go_clean_modcache
|
||||
|
||||
# Using file module since go clean --modcache is just a wrapper for rm -rf $GOMODCACHE
|
||||
- name: Clean Go modcache
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: "{{ gomodcache_path.stdout }}"
|
||||
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.stdout"
|
||||
|
||||
@@ -76,7 +76,7 @@ RUN apt-get clean && \
|
||||
RUN touch /logs/mariadb.log /logs/mariadb_script.log /logs/rabbitmq.log
|
||||
RUN chmod 777 /logs/mariadb.log /logs/mariadb_script.log /logs/rabbitmq.log
|
||||
|
||||
RUN wget -O go.tgz "https://storage.googleapis.com/golang/go1.23.1.linux-amd64.tar.gz" --progress=dot:giga
|
||||
RUN wget -O go.tgz "https://storage.googleapis.com/golang/go1.24.0.linux-amd64.tar.gz" --progress=dot:giga
|
||||
RUN tar -C /usr/local -xzf go.tgz
|
||||
RUN rm go.tgz
|
||||
|
||||
|
||||
Reference in New Issue
Block a user