Revise cgrates ansible role

Removed clone_repository variable from defaults. Now if it's not found
we will assume it's true.

In the cgrates building task we are not forcibly sourcing the /etc/profile
script anymore since it's redundant (we are using bash -lc to execute the
script, where -l will do that automatically).

Make sure we create symbolic links for all binaries we build (not just cgr-engine).
This meant the migrator task environment field could be removed as well.
This commit is contained in:
ionutboangiu
2023-08-11 07:26:06 -04:00
committed by Dan Christian Bogos
parent b97a669fd0
commit 2e6fbf9434
2 changed files with 11 additions and 10 deletions

View File

@@ -1,6 +1,5 @@
---
golang_gopath: "/home/{{ ansible_user }}/go"
clone_repository: true
cgrates_dir: "{{ golang_gopath }}/src/github.com/cgrates/cgrates"
golang_install_dir: /usr/local/go
git_version: "v0.10"

View File

@@ -13,7 +13,7 @@
mode: "u=rwx,go=rx"
owner: "{{ ansible_user }}"
dest: "{{ cgrates_dir }}"
when: "clone_repository|bool"
when: clone_repository | default(true)
- name: Git clone cgrates
ansible.builtin.git:
@@ -22,11 +22,11 @@
update: yes
force: yes
version: "{{ git_version }}"
when: "clone_repository|bool"
when: clone_repository | default(true)
- name: Build cgrates
ansible.builtin.command:
cmd: bash -lc "source /etc/profile.d/golang.sh && sh {{ cgrates_dir }}/build.sh"
ansible.builtin.shell:
cmd: bash -lc "sh {{ cgrates_dir }}/build.sh"
args:
chdir: "{{ cgrates_dir }}"
become_user: "{{ ansible_user }}"
@@ -40,9 +40,13 @@
loop:
- { src: "{{ cgrates_dir }}/data", dest: "/usr/share/cgrates" }
- { src: "{{ golang_gopath }}/bin/cgr-engine", dest: "/usr/bin/cgr-engine" }
- { src: "{{ golang_gopath }}/bin/cgr-loader", dest: "/usr/bin/cgr-loader" }
- { src: "{{ golang_gopath }}/bin/cgr-migrator", dest: "/usr/bin/cgr-migrator" }
- { src: "{{ golang_gopath }}/bin/cgr-console", dest: "/usr/bin/cgr-console" }
- { src: "{{ golang_gopath }}/bin/cgr-tester", dest: "/usr/bin/cgr-tester" }
- name: Run post install scripts
ansible.builtin.shell:
ansible.builtin.command:
cmd: "{{ item.cmd }}"
chdir: "{{ cgrates_dir }}/data/storage/{{ item.db }}"
become: yes
@@ -50,11 +54,9 @@
- { db: "mysql", cmd: "sh setup_ers_db.sh root CGRateS.org localhost" }
- { db: "mysql", cmd: "sh setup_cgr_db.sh root CGRateS.org localhost" }
- { db: "postgres", cmd: "sh setup_cgr_db.sh" }
# - { db: "postgres", cmd: "sh create_ers_db.sh" }
- { db: "postgres", cmd: "sh create_ers_db.sh" }
- { db: "mongo", cmd: "sh setup_cgr_db.sh" }
- name: Set versions
ansible.builtin.shell:
ansible.builtin.command:
cmd: "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 }}"