port calls ansible playbooks

This commit is contained in:
ionutboangiu
2024-08-28 13:38:54 +03:00
committed by Dan Christian Bogos
parent fa1fa05af6
commit 66b334f6fb
16 changed files with 91 additions and 1050 deletions

View File

@@ -1,76 +0,0 @@
---
- name: create cgrates directory
become: yes
file:
state: directory
mode: 'u=rwx,go=rx'
owner: "{{ user }}"
group: "{{ user }}"
dest: '{{ cgrates_dir }}'
become_user: "{{ user }}"
- name: git clone cgrates
git:
repo: https://github.com/cgrates/cgrates.git
dest: '{{ cgrates_dir }}'
update: yes
force: yes
become: yes
become_user: "{{ user }}"
- name: build cgrates
shell: "sh {{ cgrates_dir }}/build.sh"
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
args:
chdir: '{{ cgrates_dir }}'
- name: symbol link
become: yes
file:
src: "{{ cgrates_dir }}/data"
dest: "/usr/share/cgrates"
state: link
- name: symbol link 2
become: yes
file:
src: "{{ golang_gopath }}/bin/cgr-engine"
dest: "/usr/bin/cgr-engine"
state: link
# post install
- name: post install for ers mysql
become: yes
command: 'sh {{ cgrates_dir }}/data/storage/mysql/setup_ers_db.sh root CGRateS.org localhost'
args:
chdir: '{{ cgrates_dir }}/data/storage/mysql/'
- name: post install mysql
become: yes
command: 'sh {{ cgrates_dir }}/data/storage/mysql/setup_cgr_db.sh root CGRateS.org localhost'
args:
chdir: '{{ cgrates_dir }}/data/storage/mysql/'
- name: post install postgres2
become: yes
command: 'sh {{ cgrates_dir }}/data/storage/postgres/create_db_with_users.sh'
args:
chdir: '{{ cgrates_dir }}/data/storage/postgres/'
- name: post install for ers postgres
become: yes
command: 'sh {{ cgrates_dir }}/data/storage/postgres/create_ers_db.sh'
args:
chdir: '{{ cgrates_dir }}/data/storage/postgres/'
- name: post install mongo
become: yes
command: 'sh {{ cgrates_dir }}/data/storage/mongo/setup_cgr_db.sh'
args:
chdir: '{{ cgrates_dir }}/data/storage/mongo/'
- 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 }}"

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,140 +1,17 @@
---
- hosts: all
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.23'
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"
rootUser : root
dependencies:
- build-essential
- git
- redis-server
- mariadb-server
- postgresql
- postgresql-contrib
- python-dev
- gcc
- make
- binutils
- libasound2-dev
- autoconf
- openssl
- libssl-dev
- libxml2-dev
- libncurses5-dev
- uuid-dev
- sqlite3
- libsqlite3-dev
- pkg-config
- libedit-dev
customPath: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
remote_user: '{{ user }}'
tasks:
###########################################################################################################################
# install dependencies
- name: Install dependencies
become: yes
apt: name={{ dependencies }} state=present
###########################################################################################################################
# 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 and config CGRateS
- name: Install and config CGRateS
include: cgrates.yaml
# Configure Asterisk
- name: Download Asterisk
become: yes
shell: "sudo wget https://downloads.asterisk.org/pub/telephony/asterisk/asterisk-18-current.tar.gz"
args:
chdir: '/tmp'
- name: Unzip Asterisk
become: yes
shell: "sudo tar xzvf asterisk-18-current.tar.gz"
args:
chdir: '/tmp'
- name: Configure Asterisk
become: yes
shell: "sudo ./configure --with-jansson-bundled"
args:
chdir: '/tmp/asterisk-18.5.0'
- name: Make Asterisk
become: yes
shell: "sudo make"
args:
chdir: '/tmp/asterisk-18.5.0'
- name: Make all Asterisk
become: yes
shell: "make all"
args:
chdir: '/tmp/asterisk-18.5.0'
- name: Make install Asterisk
become: yes
shell: "sudo make install"
args:
chdir: '/tmp/asterisk-18.5.0'
- name: Make samples Asterisk
become: yes
shell: "sudo make samples"
args:
chdir: '/tmp/asterisk-18.5.0'
- name: Make config Asterisk
become: yes
shell: "sudo make config"
args:
chdir: '/tmp/asterisk-18.5.0'
- name: Add user for Asterisk
become: yes
shell: 'sudo adduser --quiet --system --group --disabled-password --shell /bin/false --gecos "Asterisk" asterisk || true'
- name: Add user for CGRateS
become: yes
shell: 'sudo useradd cgrates'
# Configure PJSUA
- name: Config PJSUA
include: pjsua.yaml
- name: Set up environment in order to run call tests for Asterisk
hosts: all
roles:
- ../../roles/asterisk
- ../../roles/go
- role: ../../roles/cgrates
vars:
cgrates_dbs:
- mysql
cgrates_dependencies:
- git
- redis-server
- mariadb-server
- role: ../../roles/pjsua
vars:
pjsua_version: '2.9'

View File

@@ -1,29 +0,0 @@
---
- name: Download PJSUA
become: yes
shell: 'sudo wget https://github.com/pjsip/pjproject/archive/refs/tags/2.9.tar.gz'
args:
chdir: '/tmp'
- name: Unzip PJSUA
become: yes
shell: 'sudo tar -xvf 2.9.tar.gz'
args:
chdir: '/tmp'
- name: Export CFLAGS
become: yes
shell: 'export CFLAGS="$CFLAGS -fPIC"'
- name: Install PJSUA
become: yes
shell: 'sudo ./configure && make dep && make && make install'
args:
chdir: '/tmp/pjproject-2.9'
- name: Copy PJSUA into /usr/bin
become: yes
shell: 'sudo mv pjsua-x86_64-unknown-linux-gnu /usr/bin/pjsua'
args:
chdir: '/tmp/pjproject-2.9/pjsip-apps/bin'

View File

@@ -1,76 +0,0 @@
---
- name: create cgrates directory
become: yes
file:
state: directory
mode: 'u=rwx,go=rx'
owner: "{{ user }}"
group: "{{ user }}"
dest: '{{ cgrates_dir }}'
become_user: "{{ user }}"
- name: git clone cgrates
git:
repo: https://github.com/cgrates/cgrates.git
dest: '{{ cgrates_dir }}'
update: yes
force: yes
become: yes
become_user: "{{ user }}"
- name: build cgrates
shell: "sh {{ cgrates_dir }}/build.sh"
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
args:
chdir: '{{ cgrates_dir }}'
- name: symbol link
become: yes
file:
src: "{{ cgrates_dir }}/data"
dest: "/usr/share/cgrates"
state: link
- name: symbol link 2
become: yes
file:
src: "{{ golang_gopath }}/bin/cgr-engine"
dest: "/usr/bin/cgr-engine"
state: link
# post install
- name: post install for ers mysql
become: yes
command: 'sh {{ cgrates_dir }}/data/storage/mysql/setup_ers_db.sh root CGRateS.org localhost'
args:
chdir: '{{ cgrates_dir }}/data/storage/mysql/'
- name: post install mysql
become: yes
command: 'sh {{ cgrates_dir }}/data/storage/mysql/setup_cgr_db.sh root CGRateS.org localhost'
args:
chdir: '{{ cgrates_dir }}/data/storage/mysql/'
- name: post install postgres2
become: yes
command: 'sh {{ cgrates_dir }}/data/storage/postgres/create_db_with_users.sh'
args:
chdir: '{{ cgrates_dir }}/data/storage/postgres/'
- name: post install for ers postgres
become: yes
command: 'sh {{ cgrates_dir }}/data/storage/postgres/create_ers_db.sh'
args:
chdir: '{{ cgrates_dir }}/data/storage/postgres/'
- name: post install mongo
become: yes
command: 'sh {{ cgrates_dir }}/data/storage/mongo/setup_cgr_db.sh'
args:
chdir: '{{ cgrates_dir }}/data/storage/mongo/'
- 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 }}"

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,133 +1,57 @@
---
- name: Install Python
- name: Set up environment in order to run call tests for Freeswitch
hosts: all
remote_user: '{{ user }}'
gather_facts: false
tasks:
- name: Install Python3s
raw: apt -y install python3
become: true
- name: Install freeswitch
ansible.builtin.import_role:
name: ../../roles/freeswitch
- name: Install Go
ansible.builtin.import_role:
name: ../../roles/go
- hosts: all
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.23'
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"
rootUser : root
freeswitch_packages:
- freeswitch-meta-all
- freeswitch-mod-json-cdr
dependencies:
- build-essential
- git
- redis-server
- mariadb-server
- postgresql
- postgresql-contrib
- python-dev
- gcc
- make
- binutils
- libasound2-dev
customPath: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
remote_user: '{{ user }}'
tasks:
###########################################################################################################################
# install dependencies
- name: Install dependencies
become: yes
apt: name={{ dependencies }} state=present
- name: apt-get update && apt-get install gnupg2
become: yes
shell: 'apt-get update && apt-get install -y gnupg2 wget lsb-release'
- name: Freeswitch add key
become: yes
shell: 'wget -O /usr/share/keyrings/freeswitch-archive-keyring.gpg https://files.freeswitch.org/repo/deb/debian-release/freeswitch-archive-keyring.gpg'
- name: Add FreeSwitch apt repository
become: yes
shell: 'echo "deb [signed-by=/usr/share/keyrings/freeswitch-archive-keyring.gpg trusted=yes] http://files.freeswitch.org/repo/deb/debian-release/ `lsb_release -sc` main" > /etc/apt/sources.list.d/freeswitch.list'
- name: Add FreeSwitch apt repository 1.8
become: yes
shell: 'echo "deb-src [signed-by=/usr/share/keyrings/freeswitch-archive-keyring.gpg trusted=yes] http://files.freeswitch.org/repo/deb/debian-unstable/ `lsb_release -sc` main" >> /etc/apt/sources.list.d/freeswitch.list'
- name: Install FreeSwitch
become: yes
shell: 'apt-get update && apt-get install -y freeswitch-meta-all'
###########################################################################################################################
# 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 and config CGRateS
- name: Install and config CGRateS
include: cgrates.yaml
ansible.builtin.import_role:
name: ../../roles/cgrates
vars:
cgrates_dbs:
- mysql
cgrates_dependencies:
- git
- redis-server
- mariadb-server
# Configure FreeSwitch
- name: Unzip FreeSWITCH config
- name: Unzip FreeSWITCH config
become: yes
shell: 'sudo tar -xvf freeswitch_conf.tar.gz'
args:
chdir: '{{ cgrates_dir }}/data/tutorial_tests/fs_evsock/freeswitch/etc'
- name: Unzip FreeSWITCH config 2
- name: Unzip FreeSWITCH config 2
become: yes
shell: 'sudo tar -xvf freeswitch_conf.tar.gz'
args:
chdir: '{{ cgrates_dir }}/data/tutorials/fs_evsock/freeswitch/etc'
- name: Remove FreeSWITCH default config from /etc/freeswitch
- name: Update internal.xml with the correct IP
ansible.builtin.replace:
path: '{{ cgrates_dir }}/data/tutorial_tests/fs_evsock/freeswitch/etc/freeswitch/sip_profiles/internal.xml'
regexp: '192\.168\.56\.203'
replace: '{{ ansible_host }}'
- name: Remove FreeSWITCH default config from /etc/freeswitch
become: yes
shell: 'sudo rm -rf *'
args:
chdir: '/etc/freeswitch'
chdir: /etc/freeswitch
- name: Copy our custom config for FreeSWITCH in /etc/freeswitch
- name: Copy our custom config for FreeSWITCH in /etc/freeswitch
become: yes
shell: 'sudo cp -r {{ cgrates_dir }}/data/tutorial_tests/fs_evsock/freeswitch/etc/freeswitch/* /etc/freeswitch'
args:
chdir: '/etc/freeswitch'
chdir: /etc/freeswitch
- name: Add user for CGRateS
become: yes
shell: 'sudo useradd cgrates'
# Configure PJSUA
- name: Config PJSUA
include: pjsua.yaml
- name: Configure PJSUA
ansible.builtin.import_role:
name: ../../roles/pjsua
vars:
pjsua_version: '2.9'

View File

@@ -1,29 +0,0 @@
---
- name: Download PJSUA
become: yes
shell: 'sudo wget https://github.com/pjsip/pjproject/archive/refs/tags/2.9.tar.gz'
args:
chdir: '/tmp'
- name: Unzip PJSUA
become: yes
shell: 'sudo tar -xvf 2.9.tar.gz'
args:
chdir: '/tmp'
- name: Export CFLAGS
become: yes
shell: 'export CFLAGS="$CFLAGS -fPIC"'
- name: Install PJSUA
become: yes
shell: 'sudo ./configure && make dep && make && make install'
args:
chdir: '/tmp/pjproject-2.9'
- name: Copy PJSUA into /usr/bin
become: yes
shell: 'sudo mv pjsua-x86_64-unknown-linux-gnu /usr/bin/pjsua'
args:
chdir: '/tmp/pjproject-2.9/pjsip-apps/bin'

View File

@@ -1,76 +0,0 @@
---
- name: create cgrates directory
become: yes
file:
state: directory
mode: 'u=rwx,go=rx'
owner: "{{ user }}"
group: "{{ user }}"
dest: '{{ cgrates_dir }}'
become_user: "{{ user }}"
- name: git clone cgrates
git:
repo: https://github.com/cgrates/cgrates.git
dest: '{{ cgrates_dir }}'
update: yes
force: yes
become: yes
become_user: "{{ user }}"
- name: build cgrates
shell: "sh {{ cgrates_dir }}/build.sh"
environment:
PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
args:
chdir: '{{ cgrates_dir }}'
- name: symbol link
become: yes
file:
src: "{{ cgrates_dir }}/data"
dest: "/usr/share/cgrates"
state: link
- name: symbol link 2
become: yes
file:
src: "{{ golang_gopath }}/bin/cgr-engine"
dest: "/usr/bin/cgr-engine"
state: link
# post install
- name: post install for ers mysql
become: yes
command: 'sh {{ cgrates_dir }}/data/storage/mysql/setup_ers_db.sh root CGRateS.org localhost'
args:
chdir: '{{ cgrates_dir }}/data/storage/mysql/'
- name: post install mysql
become: yes
command: 'sh {{ cgrates_dir }}/data/storage/mysql/setup_cgr_db.sh root CGRateS.org localhost'
args:
chdir: '{{ cgrates_dir }}/data/storage/mysql/'
- name: post install postgres2
become: yes
command: 'sh {{ cgrates_dir }}/data/storage/postgres/create_db_with_users.sh'
args:
chdir: '{{ cgrates_dir }}/data/storage/postgres/'
- name: post install for ers postgres
become: yes
command: 'sh {{ cgrates_dir }}/data/storage/postgres/create_ers_db.sh'
args:
chdir: '{{ cgrates_dir }}/data/storage/postgres/'
- name: post install mongo
become: yes
command: 'sh {{ cgrates_dir }}/data/storage/mongo/setup_cgr_db.sh'
args:
chdir: '{{ cgrates_dir }}/data/storage/mongo/'
- 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 }}"

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,87 +1,16 @@
---
- hosts: all
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.23'
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"
rootUser : root
kamailio_package:
- kamailio
- kamailio-extra-modules
- kamailio-json-modules
dependencies:
- build-essential
- git
- wget
- redis-server
- mariadb-server
- postgresql
- postgresql-contrib
- python-dev
- gcc
- make
- binutils
- libasound2-dev
customPath: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}"
remote_user: '{{ user }}'
tasks:
###########################################################################################################################
# install dependencies
- name: Install dependencies
become: yes
apt: name={{ dependencies }} state=present
# Install Kamailio
- name: Install Kamailio
become: yes
apt: name={{ kamailio_package }} state=latest
###########################################################################################################################
# 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 and config CGRateS
- name: Install and config CGRateS
include: cgrates.yaml
- name: Add user for CGRateS
become: yes
shell: 'sudo useradd cgrates'
# Configure PJSUA
- name: Config PJSUA
include: pjsua.yaml
roles:
- ../../roles/kamailio
- ../../roles/go
- role: ../../roles/cgrates
vars:
cgrates_dbs:
- mysql
cgrates_dependencies:
- git
- redis-server
- mariadb-server
- role: ../../roles/pjsua
vars:
pjsua_version: '2.9'

View File

@@ -1,29 +0,0 @@
---
- name: Download PJSUA
become: yes
shell: 'sudo wget https://github.com/pjsip/pjproject/archive/refs/tags/2.9.tar.gz'
args:
chdir: '/tmp'
- name: Unzip PJSUA
become: yes
shell: 'sudo tar -xvf 2.9.tar.gz'
args:
chdir: '/tmp'
- name: Export CFLAGS
become: yes
shell: 'export CFLAGS="$CFLAGS -fPIC"'
- name: Install PJSUA
become: yes
shell: 'sudo ./configure && make dep && make && make install'
args:
chdir: '/tmp/pjproject-2.9'
- name: Copy PJSUA into /usr/bin
become: yes
shell: 'sudo mv pjsua-x86_64-unknown-linux-gnu /usr/bin/pjsua'
args:
chdir: '/tmp/pjproject-2.9/pjsip-apps/bin'

View File

@@ -0,0 +1,28 @@
---
- hosts: all
roles:
- ../../roles/go
- role: ../../roles/cgrates
vars:
cgrates_dbs:
- mysql
cgrates_dependencies:
- git
- redis-server
- mariadb-server
- role: ../../roles/opensips
vars:
opensips_cfg_path: /usr/share/cgrates/tutorial_tests/osips/opensips/etc/opensips/opensips.cfg
- role: ../../roles/pjsua
vars:
pjsua_version: '2.9'
post_tasks:
- name: Update USER and GROUP inside cgrates init.d script
ansible.builtin.lineinfile:
path: /usr/share/cgrates/tutorial_tests/osips/cgrates/etc/init.d/cgrates
regexp: '^{{ item.key }}='
line: '{{ item.key }}={{ ansible_user_id }}'
loop:
- { key: 'USER' }
- { key: 'GROUP' }