Remove go.yaml files in favour of install_go role

This commit is contained in:
ionutboangiu
2023-05-11 04:43:01 -04:00
committed by Dan Christian Bogos
parent dc2741c025
commit f3807bc656
17 changed files with 70 additions and 887 deletions

View File

@@ -1,122 +0,0 @@
---
- name: create gopath directory
file:
state: directory
mode: 'u=rwx,go=rx'
dest: '{{ golang_gopath }}'
- name: create download directory
file:
state: directory
mode: 'u=rwx,go=rx'
dest: '{{ golang_download_dir }}'
- name: Register the current Go version (if any)
command: /usr/local/go/bin/go version
ignore_errors: yes
register: go_version
changed_when: false
- name: Remove old installation of Go
become: yes
file:
path: /usr/local/go
state: absent
when: go_version is false or go_version.stdout != go_version_target
- name: download Go language SDK
get_url:
url: '{{ golang_mirror }}/{{ golang_redis_filename }}'
dest: '{{ golang_download_dir }}/{{ golang_redis_filename }}'
mode: 'u=rw,go=r'
- name: create Go language SDK installation directory
become: yes
file:
state: directory
owner: root
group: root
mode: 'u=rwx,go=rx'
dest: '{{ golang_install_dir }}'
- name: install Go language SDK
become: yes
unarchive:
src: '{{ golang_download_dir }}/{{ golang_redis_filename }}'
remote_src: yes
extra_opts: '--strip-components=1'
dest: '{{ golang_install_dir }}'
owner: root
group: root
creates: '{{ golang_install_dir }}/bin'
# Set Go language SDK environment variables
- name: make sure /etc/profile.d exists
become: yes
file:
path: /etc/profile.d
state: directory
owner: root
group: root
mode: 'u=rwx,go=rx'
- name: export Go language SDK environment variables
become: yes
template:
src: golang.sh.j2
dest: /etc/profile.d/golang.sh
owner: root
group: root
mode: 'u=rw,go=r'
- name: Export GOROOT for root
become: yes
lineinfile:
path: ~/.bashrc
line: export GOROOT='{{ golang_install_dir }}'
insertafter: last
- name: Add GOROOT to PATH for root
become: yes
lineinfile:
dest: ~/.bashrc
line: export PATH=$PATH:$GOROOT/bin
insertafter: last
- name: Export GOPATH for root
become: yes
lineinfile:
dest: ~/.bashrc
line: export GOPATH='{{ golang_gopath }}'
insertafter: last
- name: Add GOPATH to PATH for root
become: yes
lineinfile:
dest: ~/.bashrc
line: export PATH=$PATH:$GOPATH/bin
insertafter: last
- name: Export GOROOT
lineinfile:
dest: ~/.bashrc
line: export GOROOT='{{ golang_install_dir }}'
insertafter: last
- name: Add GOROOT to PATH
lineinfile:
dest: ~/.bashrc
line: export PATH=$PATH:$GOROOT/bin
insertafter: last
- name: Export GOPATH
lineinfile:
dest: ~/.bashrc
line: export GOPATH='{{ golang_gopath }}'
insertafter: last
- name: Add GOPATH to PATH
lineinfile:
dest: ~/.bashrc
line: export PATH=$PATH:$GOPATH/bin
insertafter: last

View File

@@ -1,12 +0,0 @@
#!/bin/sh
{{ ansible_managed | comment('plain') }}
export GOROOT='{{ golang_install_dir }}'
export PATH=$PATH:$GOROOT/bin
{% if golang_gopath not in (None, '') %}
export GOPATH="{{ golang_gopath }}"
export PATH=$PATH:$GOPATH/bin
{% endif %}

View File

@@ -1,25 +1,10 @@
- hosts: pkg
vars:
# Go language SDK version number
golang_version: '1.19.2'
go_version_target: "go version go{{ golang_version }} linux/amd64"
# Mirror to download the Go language SDK redistributable package from
golang_mirror: 'https://storage.googleapis.com/golang'
# Base installation directory the Go language SDK distribution
golang_install_dir: '/usr/local/go'
# Directory to store files downloaded for Go language SDK installation
golang_download_dir: "{{ x_ansible_download_dir | default(ansible_env.HOME + '/.ansible/tmp/downloads') }}"
# Location for GOPATH environment variable
golang_gopath: "/home/{{ user }}/go"
# Filename of Go language SDK redistributable package
golang_redis_filename: 'go{{ golang_version }}.linux-amd64.tar.gz'
coprgate_dir: "/home/{{ user }}/go/src/github.com/cgrates/coprgate"
coprgate_bin: "{{ golang_gopath }}/bin/coprgate"
coprgate_bin: "/home/{{ user }}/go/bin/coprgate"
service_name: coprgate
tasks:
- name: Install dependencies
become: yes
apt:
@@ -27,8 +12,9 @@
- git
- tar
state: present
- name: Install golang
include: go.yaml
- name: Install Go
import_role:
name: ../roles/install_go
- name: Create coprgate directory
become: yes
@@ -52,7 +38,7 @@
- name: Install coprgate
shell: "go install coprgate.go"
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
args:
chdir: '{{ coprgate_dir }}'

View File

@@ -1,122 +0,0 @@
---
- name: create gopath directory
file:
state: directory
mode: 'u=rwx,go=rx'
dest: '{{ golang_gopath }}'
- name: create download directory
file:
state: directory
mode: 'u=rwx,go=rx'
dest: '{{ golang_download_dir }}'
- name: Register the current Go version (if any)
command: /usr/local/go/bin/go version
ignore_errors: yes
register: go_version
changed_when: false
- name: Remove old installation of Go
become: yes
file:
path: /usr/local/go
state: absent
when: go_version is failed or go_version.stdout != go_version_target
- name: download Go language SDK
get_url:
url: '{{ golang_mirror }}/{{ golang_redis_filename }}'
dest: '{{ golang_download_dir }}/{{ golang_redis_filename }}'
mode: 'u=rw,go=r'
- name: create Go language SDK installation directory
become: yes
file:
state: directory
owner: root
group: root
mode: 'u=rwx,go=rx'
dest: '{{ golang_install_dir }}'
- name: install Go language SDK
become: yes
unarchive:
src: '{{ golang_download_dir }}/{{ golang_redis_filename }}'
remote_src: yes
extra_opts: '--strip-components=1'
dest: '{{ golang_install_dir }}'
owner: root
group: root
creates: '{{ golang_install_dir }}/bin'
# Set Go language SDK environment variables
- name: make sure /etc/profile.d exists
become: yes
file:
path: /etc/profile.d
state: directory
owner: root
group: root
mode: 'u=rwx,go=rx'
- name: export Go language SDK environment variables
become: yes
template:
src: golang.sh.j2
dest: /etc/profile.d/golang.sh
owner: root
group: root
mode: 'u=rw,go=r'
- name: Export GOROOT for root
become: yes
lineinfile:
path: ~/.bashrc
line: export GOROOT='{{ golang_install_dir }}'
insertafter: last
- name: Add GOROOT to PATH for root
become: yes
lineinfile:
dest: ~/.bashrc
line: export PATH=$PATH:$GOROOT/bin
insertafter: last
- name: Export GOPATH for root
become: yes
lineinfile:
dest: ~/.bashrc
line: export GOPATH='{{ golang_gopath }}'
insertafter: last
- name: Add GOPATH to PATH for root
become: yes
lineinfile:
dest: ~/.bashrc
line: export PATH=$PATH:$GOPATH/bin
insertafter: last
- name: Export GOROOT
lineinfile:
dest: ~/.bashrc
line: export GOROOT='{{ golang_install_dir }}'
insertafter: last
- name: Add GOROOT to PATH
lineinfile:
dest: ~/.bashrc
line: export PATH=$PATH:$GOROOT/bin
insertafter: last
- name: Export GOPATH
lineinfile:
dest: ~/.bashrc
line: export GOPATH='{{ golang_gopath }}'
insertafter: last
- name: Add GOPATH to PATH
lineinfile:
dest: ~/.bashrc
line: export PATH=$PATH:$GOPATH/bin
insertafter: last

View File

@@ -1,12 +0,0 @@
#!/bin/sh
{{ ansible_managed | comment('plain') }}
export GOROOT='{{ golang_install_dir }}'
export PATH=$PATH:$GOROOT/bin
{% if golang_gopath not in (None, '') %}
export GOPATH="{{ golang_gopath }}"
export PATH=$PATH:$GOPATH/bin
{% endif %}

View File

@@ -1,27 +1,8 @@
---
- hosts: apt
vars:
ansible_python_interpreter: auto # to disable deprication warning related to the use of python2
###############################################################
##################### Golang Vars #############################
###############################################################
# Go language SDK version number
golang_version: '1.17.5'
go_version_target: "go version go{{ golang_version }} linux/amd64"
# Mirror to download the Go language SDK redistributable package from
golang_mirror: 'https://storage.googleapis.com/golang'
# Base installation directory the Go language SDK distribution
golang_install_dir: '/usr/local/go'
# Directory to store files downloaded for Go language SDK installation
golang_download_dir: "{{ x_ansible_download_dir | default(ansible_env.HOME + '/.ansible/tmp/downloads') }}"
# Location for GOPATH environment variable
golang_gopath: "/home/{{ user }}/go"
# Filename of Go language SDK redistributable package
golang_redis_filename: 'go{{ golang_version }}.linux-amd64.tar.gz'
###############################################################
# CGRateS vars
cgrates_dir: "{{ golang_gopath }}/src/github.com/cgrates/cgrates"
cgrates_dir: "/home/{{ user }}/go/src/github.com/cgrates/cgrates"
cgrates_branch: "v0.10"
cgrates_distribution: "nightly"
###############################################################
@@ -38,7 +19,7 @@
rootUser : root
customPath: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
customPath: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
dependencies:
- build-essential
@@ -86,18 +67,10 @@
###########################################################################################################################
###########################################################################################################################
# Install Golang
- name: install unarchive dependencies (zypper)
become: yes
zypper:
name:
- gzip
- tar
state: present
when: ansible_pkg_mgr == 'zypper'
- name: Install golang
include: go.yaml
# Install Go
- name: Install Go
import_role:
name: ../roles/install_go
###########################################################################################################################
###########################################################################################################################
@@ -126,26 +99,26 @@
become: yes
shell: "go clean --cache"
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
- name: clean go modcache
become: yes
shell: "go clean --modcache"
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
- name: sync the go mod with vendor
become: yes
shell: "go mod vendor"
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
args:
chdir: '{{ cgrates_dir }}'
- name: build cgrates
shell: "sh {{ cgrates_dir }}/build.sh"
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
args:
chdir: '{{ cgrates_dir }}'
@@ -172,7 +145,7 @@
- name: Check if the package was generated
become: yes
shell: "sudo ls {{ golang_gopath }}/src/github.com/cgrates | grep 'cgrates_'"
shell: "sudo ls /home/{{ user }}/go/src/github.com/cgrates | grep 'cgrates_'"
ignore_errors: true
register: packageVar
@@ -180,7 +153,7 @@
become: yes
command: sudo mv {{item}} /var/packages/debian/incoming/
args:
chdir: '{{ golang_gopath }}/src/github.com/cgrates'
chdir: '/home/{{ user }}/go/src/github.com/cgrates'
when : packageVar.stdout_lines|length > 0
with_items: '{{ packageVar.stdout_lines }}'

View File

@@ -1,122 +0,0 @@
---
- name: create gopath directory
file:
state: directory
mode: 'u=rwx,go=rx'
dest: '{{ golang_gopath }}'
- name: create download directory
file:
state: directory
mode: 'u=rwx,go=rx'
dest: '{{ golang_download_dir }}'
- name: Register the current Go version (if any)
command: /usr/local/go/bin/go version
ignore_errors: yes
register: go_version
changed_when: false
- name: Remove old installation of Go
become: yes
file:
path: /usr/local/go
state: absent
when: go_version is failed or go_version.stdout != go_version_target
- name: download Go language SDK
get_url:
url: '{{ golang_mirror }}/{{ golang_redis_filename }}'
dest: '{{ golang_download_dir }}/{{ golang_redis_filename }}'
mode: 'u=rw,go=r'
- name: create Go language SDK installation directory
become: yes
file:
state: directory
owner: root
group: root
mode: 'u=rwx,go=rx'
dest: '{{ golang_install_dir }}'
- name: install Go language SDK
become: yes
unarchive:
src: '{{ golang_download_dir }}/{{ golang_redis_filename }}'
remote_src: yes
extra_opts: '--strip-components=1'
dest: '{{ golang_install_dir }}'
owner: root
group: root
creates: '{{ golang_install_dir }}/bin'
# Set Go language SDK environment variables
- name: make sure /etc/profile.d exists
become: yes
file:
path: /etc/profile.d
state: directory
owner: root
group: root
mode: 'u=rwx,go=rx'
- name: export Go language SDK environment variables
become: yes
template:
src: golang.sh.j2
dest: /etc/profile.d/golang.sh
owner: root
group: root
mode: 'u=rw,go=r'
- name: Export GOROOT for root
become: yes
lineinfile:
path: ~/.bashrc
line: export GOROOT='{{ golang_install_dir }}'
insertafter: last
- name: Add GOROOT to PATH for root
become: yes
lineinfile:
dest: ~/.bashrc
line: export PATH=$PATH:$GOROOT/bin
insertafter: last
- name: Export GOPATH for root
become: yes
lineinfile:
dest: ~/.bashrc
line: export GOPATH='{{ golang_gopath }}'
insertafter: last
- name: Add GOPATH to PATH for root
become: yes
lineinfile:
dest: ~/.bashrc
line: export PATH=$PATH:$GOPATH/bin
insertafter: last
- name: Export GOROOT
lineinfile:
dest: ~/.bashrc
line: export GOROOT='{{ golang_install_dir }}'
insertafter: last
- name: Add GOROOT to PATH
lineinfile:
dest: ~/.bashrc
line: export PATH=$PATH:$GOROOT/bin
insertafter: last
- name: Export GOPATH
lineinfile:
dest: ~/.bashrc
line: export GOPATH='{{ golang_gopath }}'
insertafter: last
- name: Add GOPATH to PATH
lineinfile:
dest: ~/.bashrc
line: export PATH=$PATH:$GOPATH/bin
insertafter: last

View File

@@ -1,12 +0,0 @@
#!/bin/sh
{{ ansible_managed | comment('plain') }}
export GOROOT='{{ golang_install_dir }}'
export PATH=$PATH:$GOROOT/bin
{% if golang_gopath not in (None, '') %}
export GOPATH="{{ golang_gopath }}"
export PATH=$PATH:$GOPATH/bin
{% endif %}

View File

@@ -1,27 +1,8 @@
---
- hosts: dkr
vars:
ansible_python_interpreter: auto # to disable deprication warning related to the use of python2
###############################################################
##################### Golang Vars #############################
###############################################################
# Go language SDK version number
golang_version: '1.17.5'
go_version_target: "go version go{{ golang_version }} linux/amd64"
# Mirror to download the Go language SDK redistributable package from
golang_mirror: 'https://storage.googleapis.com/golang'
# Base installation directory the Go language SDK distribution
golang_install_dir: '/usr/local/go'
# Directory to store files downloaded for Go language SDK installation
golang_download_dir: "{{ x_ansible_download_dir | default(ansible_env.HOME + '/.ansible/tmp/downloads') }}"
# Location for GOPATH environment variable
golang_gopath: "/home/{{ user }}/go"
# Filename of Go language SDK redistributable package
golang_redis_filename: 'go{{ golang_version }}.linux-amd64.tar.gz'
###############################################################
# CGRateS vars
cgrates_dir: "{{ golang_gopath }}/src/github.com/cgrates/cgrates"
cgrates_dir: "/home/{{ user }}/go/src/github.com/cgrates/cgrates"
cgrates_branch: "v0.10"
cgrates_distribution: "nightly"
docker_tag: "latest"
@@ -91,18 +72,10 @@
###########################################################################################################################
###########################################################################################################################
# Install Golang
- name: install unarchive dependencies (zypper)
become: yes
zypper:
name:
- gzip
- tar
state: present
when: ansible_pkg_mgr == 'zypper'
- name: Install golang
include: go.yaml
# Install Go
- name: Install Go
import_role:
name: ../roles/install_go
###########################################################################################################################
###########################################################################################################################
@@ -138,18 +111,18 @@
become: yes
shell: "go clean --cache"
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
- name: clean go modcache
become: yes
shell: "go clean --modcache"
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
- name: build cgrates for docker
shell: "sh {{ cgrates_dir }}/data/docker/scratch/build.sh"
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
args:
chdir: '{{ cgrates_dir }}/data/docker/scratch'
@@ -157,13 +130,13 @@
become: yes
shell: "go clean --cache"
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
- name: clean go modcache after build
become: yes
shell: "go clean --modcache"
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
- name: copy certificate authority
copy:

View File

@@ -1,26 +1,8 @@
---
- hosts: ci
vars:
ansible_python_interpreter: auto # to disable deprication warning related to the use of python2
###############################################################
##################### Golang Vars #############################
###############################################################
# Go language SDK version number
golang_version: '1.17.5'
go_version_target: "go version go{{ golang_version }} linux/amd64"
# Mirror to download the Go language SDK redistributable package from
golang_mirror: 'https://storage.googleapis.com/golang'
# Base installation directory the Go language SDK distribution
golang_install_dir: '/usr/local/go'
# Directory to store files downloaded for Go language SDK installation
golang_download_dir: "{{ x_ansible_download_dir | default(ansible_env.HOME + '/.ansible/tmp/downloads') }}"
# Location for GOPATH environment variable
golang_gopath: "/home/{{ user }}/go"
# Filename of Go language SDK redistributable package
golang_redis_filename: 'go{{ golang_version }}.linux-amd64.tar.gz'
#################################################################
cgrates_dir: "{{ golang_gopath }}/src/github.com/cgrates/cgrates"
cgrates_dir: "/home/{{ user }}/go/src/github.com/cgrates/cgrates"
#################################################################
drone_dir: "/home/{{ user }}/go/src/github.com/drone/drone"
@@ -65,18 +47,10 @@
include: docker.yaml
###########################################################################################################################
###########################################################################################################################
# Install Golang
- name: install unarchive dependencies (zypper)
become: yes
zypper:
name:
- gzip
- tar
state: present
when: ansible_pkg_mgr == 'zypper'
- name: Install golang
include: go.yaml
# Install Go
- name: Install Go
import_role:
name: ../roles/install_go
###########################################################################################################################
###########################################################################################################################
@@ -84,13 +58,13 @@
become: yes
shell: "go clean --cache"
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
- name: clean go modcache
become: yes
shell: "go clean --modcache"
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
- name: create mailer directory
become: yes
@@ -99,13 +73,13 @@
mode: 'u=rwx,go=rx'
owner: "{{ user }}"
group: "{{ user }}"
dest: '{{ golang_gopath }}/src/github.com/Trial97/drone-email'
dest: '/home/{{ user }}/go/src/github.com/Trial97/drone-email'
become_user: "{{ user }}"
- name: git clone mailer
git:
repo: https://github.com/Trial97/drone-email.git
dest: '{{ golang_gopath }}/src/github.com/Trial97/drone-email'
dest: '/home/{{ user }}/go/src/github.com/Trial97/drone-email'
update: yes
force: yes
version: "master"
@@ -114,9 +88,9 @@
- name: build Docker image for mail plugin
become: yes
shell: docker build -t trial97/drone-email {{ golang_gopath }}/src/github.com/Trial97/drone-email
shell: docker build -t trial97/drone-email /home/{{ user }}/go/src/github.com/Trial97/drone-email
args:
chdir: '{{ golang_gopath }}/src/github.com/Trial97/drone-email'
chdir: '/home/{{ user }}/go/src/github.com/Trial97/drone-email'
- name: create drone-cli directory
@@ -126,13 +100,13 @@
mode: 'u=rwx,go=rx'
owner: "{{ user }}"
group: "{{ user }}"
dest: '{{ golang_gopath }}/src/github.com/drone/drone-cli'
dest: '/home/{{ user }}/go/src/github.com/drone/drone-cli'
become_user: "{{ user }}"
- name: git clone mailer
git:
repo: https://github.com/drone/drone-cli.git
dest: '{{ golang_gopath }}/src/github.com/drone/drone-cli'
dest: '/home/{{ user }}/go/src/github.com/drone/drone-cli'
update: yes
force: yes
version: "master"
@@ -140,11 +114,11 @@
become_user: "{{ user }}"
- name: build drone-cli
shell: go build -o {{ golang_gopath }}/bin/drone-cli ./main.go
shell: go build -o /home/{{ user }}/go/bin/drone-cli ./main.go
args:
chdir: '{{ golang_gopath }}/src/github.com/drone/drone-cli/drone'
chdir: '/home/{{ user }}/go/src/github.com/drone/drone-cli/drone'
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
- name: create cgrates directory
become: yes
@@ -207,14 +181,14 @@
- name: build drone
shell: "go install github.com/drone/drone/cmd/drone-server"
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
args:
chdir: '{{ drone_dir }}'
- name: install validate plugin
shell: "go get github.com/Trial97/droneAuth"
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
- name: export users
template:
@@ -240,7 +214,7 @@
async: 10
poll: 0
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
- name: start drone
become: yes
@@ -248,7 +222,7 @@
async: 10
poll: 0
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
- name: Check if drone-runner is running
become: yes
@@ -276,7 +250,7 @@
drone-cli orgsecret add {{ item }} credentials @/home/{{ user }}/credentials.json --allow-pull-request;
drone-cli orgsecret add {{ item }} token @/home/{{ user }}/token.json --allow-pull-request;
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
DRONE_SERVER: "https://{{ drone_server_host }}"
DRONE_TOKEN: "{{ drone_token.stdout }}"
with_items: '{{ drone_user_filter }}'

View File

@@ -1,122 +0,0 @@
---
- name: create gopath directory
file:
state: directory
mode: 'u=rwx,go=rx'
dest: '{{ golang_gopath }}'
- name: create download directory
file:
state: directory
mode: 'u=rwx,go=rx'
dest: '{{ golang_download_dir }}'
- name: Register the current Go version (if any)
command: /usr/local/go/bin/go version
ignore_errors: yes
register: go_version
changed_when: false
- name: Remove old installation of Go
become: yes
file:
path: /usr/local/go
state: absent
when: go_version is failed or go_version.stdout != go_version_target
- name: download Go language SDK
get_url:
url: '{{ golang_mirror }}/{{ golang_redis_filename }}'
dest: '{{ golang_download_dir }}/{{ golang_redis_filename }}'
mode: 'u=rw,go=r'
- name: create Go language SDK installation directory
become: yes
file:
state: directory
owner: root
group: root
mode: 'u=rwx,go=rx'
dest: '{{ golang_install_dir }}'
- name: install Go language SDK
become: yes
unarchive:
src: '{{ golang_download_dir }}/{{ golang_redis_filename }}'
remote_src: yes
extra_opts: '--strip-components=1'
dest: '{{ golang_install_dir }}'
owner: root
group: root
creates: '{{ golang_install_dir }}/bin'
# Set Go language SDK environment variables
- name: make sure /etc/profile.d exists
become: yes
file:
path: /etc/profile.d
state: directory
owner: root
group: root
mode: 'u=rwx,go=rx'
- name: export Go language SDK environment variables
become: yes
template:
src: golang.sh.j2
dest: /etc/profile.d/golang.sh
owner: root
group: root
mode: 'u=rw,go=r'
- name: Export GOROOT for root
become: yes
lineinfile:
path: ~/.bashrc
line: export GOROOT='{{ golang_install_dir }}'
insertafter: last
- name: Add GOROOT to PATH for root
become: yes
lineinfile:
dest: ~/.bashrc
line: export PATH=$PATH:$GOROOT/bin
insertafter: last
- name: Export GOPATH for root
become: yes
lineinfile:
dest: ~/.bashrc
line: export GOPATH='{{ golang_gopath }}'
insertafter: last
- name: Add GOPATH to PATH for root
become: yes
lineinfile:
dest: ~/.bashrc
line: export PATH=$PATH:$GOPATH/bin
insertafter: last
- name: Export GOROOT
lineinfile:
dest: ~/.bashrc
line: export GOROOT='{{ golang_install_dir }}'
insertafter: last
- name: Add GOROOT to PATH
lineinfile:
dest: ~/.bashrc
line: export PATH=$PATH:$GOROOT/bin
insertafter: last
- name: Export GOPATH
lineinfile:
dest: ~/.bashrc
line: export GOPATH='{{ golang_gopath }}'
insertafter: last
- name: Add GOPATH to PATH
lineinfile:
dest: ~/.bashrc
line: export PATH=$PATH:$GOPATH/bin
insertafter: last

View File

@@ -1,12 +0,0 @@
#!/bin/sh
{{ ansible_managed | comment('plain') }}
export GOROOT='{{ golang_install_dir }}'
export PATH=$PATH:$GOROOT/bin
{% if golang_gopath not in (None, '') %}
export GOPATH="{{ golang_gopath }}"
export PATH=$PATH:$GOPATH/bin
{% endif %}

View File

@@ -1,23 +1,6 @@
---
- hosts: local
vars:
ansible_python_interpreter: auto # to disable deprication warning related to the use of python2
###############################################################
##################### Golang Vars #############################
###############################################################
# Go language SDK version number
golang_version: '1.17.5'
go_version_target: "go version go{{ golang_version }} linux/amd64"
# Mirror to download the Go language SDK redistributable package from
golang_mirror: 'https://storage.googleapis.com/golang'
# Base installation directory the Go language SDK distribution
golang_install_dir: '/usr/local/go'
# Directory to store files downloaded for Go language SDK installation
golang_download_dir: "{{ x_ansible_download_dir | default(ansible_env.HOME + '/.ansible/tmp/downloads') }}"
# Location for GOPATH environment variable
golang_gopath: "/home/{{ user }}/go"
# Filename of Go language SDK redistributable package
golang_redis_filename: 'go{{ golang_version }}.linux-amd64.tar.gz'
###############################################################
###################### Kafka Vars #############################
###############################################################
@@ -33,7 +16,7 @@
###############################################################
# CGRateS location
cgrates_dir: "{{ golang_gopath }}/src/github.com/cgrates/cgrates"
cgrates_dir: "/home/{{ user }}/go/src/github.com/cgrates/cgrates"
###############################################################
remote_user: root
tasks:
@@ -85,18 +68,9 @@
###########################################################################################################################
###########################################################################################################################
# install golang
- name: install unarchive dependencies (zypper)
become: yes
zypper:
name:
- gzip
- tar
state: present
when: ansible_pkg_mgr == 'zypper'
- name: Install golang
include: go.yaml
- name: Install Go
import_role:
name: ../roles/install_go
###########################################################################################################################
@@ -121,7 +95,7 @@
- name: build cgrates
command: 'sh {{ cgrates_dir }}/build.sh'
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
args:
chdir: '{{ cgrates_dir }}'
@@ -168,4 +142,4 @@
- name: set versions
command: 'cgr-migrator -exec=*set_versions -config_path=/usr/share/cgrates/conf/samples/tutmysql'
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"

View File

@@ -85,11 +85,11 @@ cp -rpf {{ cgrates_dir }}/data/storage/mongo $RPM_BUILD_ROOT%{_datarootdir}/%{na
cp -rpf {{ cgrates_dir }}/data/storage/mysql $RPM_BUILD_ROOT%{_datarootdir}/%{name}/storage
cp -rpf {{ cgrates_dir }}/data/storage/postgres $RPM_BUILD_ROOT%{_datarootdir}/%{name}/storage
install -D -m 0644 -p {{ cgrates_dir }}/data/conf/%{name}/%{name}.json $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/%{name}.json
install -D -m 0755 -p {{ golang_gopath }}/bin/cgr-console $RPM_BUILD_ROOT%{_bindir}/cgr-console
install -D -m 0755 -p {{ golang_gopath }}/bin/cgr-engine $RPM_BUILD_ROOT%{_bindir}/cgr-engine
install -D -m 0755 -p {{ golang_gopath }}/bin/cgr-loader $RPM_BUILD_ROOT%{_bindir}/cgr-loader
install -D -m 0755 -p {{ golang_gopath }}/bin/cgr-tester $RPM_BUILD_ROOT%{_bindir}/cgr-tester
install -D -m 0755 -p {{ golang_gopath }}/bin/cgr-migrator $RPM_BUILD_ROOT%{_bindir}/cgr-migrator
install -D -m 0755 -p /home/{{ user }}/go/bin/cgr-console $RPM_BUILD_ROOT%{_bindir}/cgr-console
install -D -m 0755 -p /home/{{ user }}/go/bin/cgr-engine $RPM_BUILD_ROOT%{_bindir}/cgr-engine
install -D -m 0755 -p /home/{{ user }}/go/bin/cgr-loader $RPM_BUILD_ROOT%{_bindir}/cgr-loader
install -D -m 0755 -p /home/{{ user }}/go/bin/cgr-tester $RPM_BUILD_ROOT%{_bindir}/cgr-tester
install -D -m 0755 -p /home/{{ user }}/go/bin/cgr-migrator $RPM_BUILD_ROOT%{_bindir}/cgr-migrator
mkdir -p $RPM_BUILD_ROOT%{_logdir}/cdre/csv
mkdir -p $RPM_BUILD_ROOT%{_logdir}/cdre/fwv
mkdir -p $RPM_BUILD_ROOT%{_spooldir}/cdre/csv

View File

@@ -1,122 +0,0 @@
---
- name: create gopath directory
file:
state: directory
mode: 'u=rwx,go=rx'
dest: '{{ golang_gopath }}'
- name: create download directory
file:
state: directory
mode: 'u=rwx,go=rx'
dest: '{{ golang_download_dir }}'
- name: Register the current Go version (if any)
command: /usr/local/go/bin/go version
ignore_errors: yes
register: go_version
changed_when: false
- name: Remove old installation of Go
become: yes
file:
path: /usr/local/go
state: absent
when: go_version is failed or go_version.stdout != go_version_target
- name: download Go language SDK
get_url:
url: '{{ golang_mirror }}/{{ golang_redis_filename }}'
dest: '{{ golang_download_dir }}/{{ golang_redis_filename }}'
mode: 'u=rw,go=r'
- name: create Go language SDK installation directory
become: yes
file:
state: directory
owner: root
group: root
mode: 'u=rwx,go=rx'
dest: '{{ golang_install_dir }}'
- name: install Go language SDK
become: yes
unarchive:
src: '{{ golang_download_dir }}/{{ golang_redis_filename }}'
remote_src: yes
extra_opts: '--strip-components=1'
dest: '{{ golang_install_dir }}'
owner: root
group: root
creates: '{{ golang_install_dir }}/bin'
# Set Go language SDK environment variables
- name: make sure /etc/profile.d exists
become: yes
file:
path: /etc/profile.d
state: directory
owner: root
group: root
mode: 'u=rwx,go=rx'
- name: export Go language SDK environment variables
become: yes
template:
src: golang.sh.j2
dest: /etc/profile.d/golang.sh
owner: root
group: root
mode: 'u=rw,go=r'
- name: Export GOROOT for root
become: yes
lineinfile:
path: ~/.bashrc
line: export GOROOT='{{ golang_install_dir }}'
insertafter: last
- name: Add GOROOT to PATH for root
become: yes
lineinfile:
dest: ~/.bashrc
line: export PATH=$PATH:$GOROOT/bin
insertafter: last
- name: Export GOPATH for root
become: yes
lineinfile:
dest: ~/.bashrc
line: export GOPATH='{{ golang_gopath }}'
insertafter: last
- name: Add GOPATH to PATH for root
become: yes
lineinfile:
dest: ~/.bashrc
line: export PATH=$PATH:$GOPATH/bin
insertafter: last
- name: Export GOROOT
lineinfile:
dest: ~/.bashrc
line: export GOROOT='{{ golang_install_dir }}'
insertafter: last
- name: Add GOROOT to PATH
lineinfile:
dest: ~/.bashrc
line: export PATH=$PATH:$GOROOT/bin
insertafter: last
- name: Export GOPATH
lineinfile:
dest: ~/.bashrc
line: export GOPATH='{{ golang_gopath }}'
insertafter: last
- name: Add GOPATH to PATH
lineinfile:
dest: ~/.bashrc
line: export PATH=$PATH:$GOPATH/bin
insertafter: last

View File

@@ -1,12 +0,0 @@
#!/bin/sh
{{ ansible_managed | comment('plain') }}
export GOROOT='{{ golang_install_dir }}'
export PATH=$PATH:$GOROOT/bin
{% if golang_gopath not in (None, '') %}
export GOPATH="{{ golang_gopath }}"
export PATH=$PATH:$GOPATH/bin
{% endif %}

View File

@@ -50,27 +50,8 @@
- hosts: yum
vars:
ansible_python_interpreter: auto # to disable deprication warning related to the use of python2
###############################################################
##################### Golang Vars #############################
###############################################################
# Go language SDK version number
golang_version: '1.19.2'
go_version_target: "go version go{{ golang_version }} linux/amd64"
# Mirror to download the Go language SDK redistributable package from
golang_mirror: 'https://storage.googleapis.com/golang'
# Base installation directory the Go language SDK distribution
golang_install_dir: '/usr/local/go'
# Directory to store files downloaded for Go language SDK installation
golang_download_dir: "{{ x_ansible_download_dir | default(ansible_env.HOME + '/.ansible/tmp/downloads') }}"
# Location for GOPATH environment variable
golang_gopath: "/home/{{ user }}/go"
# Filename of Go language SDK redistributable package
golang_redis_filename: 'go{{ golang_version }}.linux-amd64.tar.gz'
###############################################################
# CGRateS location
cgrates_dir: "{{ golang_gopath }}/src/github.com/cgrates/cgrates"
cgrates_dir: "/home/{{ user }}/go/src/github.com/cgrates/cgrates"
cgrates_branch: "v0.10"
cgrates_distribution: "nightly"
###############################################################
@@ -87,7 +68,7 @@
rootUser : root
customPath: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
customPath: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
ansible_user: '{{ user }}'
tasks:
@@ -181,18 +162,10 @@
###########################################################################################################################
###########################################################################################################################
# Install Golang
- name: install unarchive dependencies (zypper)
become: yes
zypper:
name:
- gzip
- tar
state: present
when: ansible_pkg_mgr == 'zypper'
- name: Install golang
include: go.yaml
# Install Go
- name: Install Go
import_role:
name: ../roles/install_go
###########################################################################################################################
###########################################################################################################################
@@ -221,26 +194,26 @@
become: yes
shell: "go clean --cache"
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
- name: clean go modcache
become: yes
shell: "go clean --modcache"
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
- name: sync the go mod with vendor
become: yes
shell: "go mod vendor"
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
args:
chdir: '{{ cgrates_dir }}'
- name: build cgrates
shell: "sh {{ cgrates_dir }}/build.sh"
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
args:
chdir: '{{ cgrates_dir }}'
@@ -312,7 +285,7 @@
become: yes
shell: 'rpmbuild -bb --define "_topdir /home/{{ user }}/cgr_build" cgr_build/SPECS/cgrates.spec'
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
PATH: "{{ lookup('env','PATH') }}:/home/{{ user }}/go/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
- name: Take the name of the .rpm package
become: yes