From c8b0016758320cfcaf1afb02eb852926cd00d425 Mon Sep 17 00:00:00 2001 From: andronache Date: Fri, 25 Jun 2021 15:50:49 +0300 Subject: [PATCH] Finished making all Ansible scripts for calls work --- data/ansible/calls/asterisk/cgrates.yaml | 2 +- data/ansible/calls/asterisk/go.yaml | 2 +- data/ansible/calls/asterisk/main.yaml | 14 +-- data/ansible/calls/freeswitch/cgrates.yaml | 28 ++++- data/ansible/calls/freeswitch/main.yaml | 123 ++++++++++++--------- data/ansible/calls/kamailio/cgrates.yaml | 28 ++++- data/ansible/calls/kamailio/main.yaml | 6 +- 7 files changed, 136 insertions(+), 67 deletions(-) diff --git a/data/ansible/calls/asterisk/cgrates.yaml b/data/ansible/calls/asterisk/cgrates.yaml index fd6fda699..51352e385 100644 --- a/data/ansible/calls/asterisk/cgrates.yaml +++ b/data/ansible/calls/asterisk/cgrates.yaml @@ -73,4 +73,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 }}" \ No newline at end of file + PATH: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}" diff --git a/data/ansible/calls/asterisk/go.yaml b/data/ansible/calls/asterisk/go.yaml index ffc9ed444..c08fae40b 100644 --- a/data/ansible/calls/asterisk/go.yaml +++ b/data/ansible/calls/asterisk/go.yaml @@ -119,4 +119,4 @@ lineinfile: dest: ~/.bashrc line: export PATH=$PATH:$GOPATH/bin - insertafter: last \ No newline at end of file + insertafter: last diff --git a/data/ansible/calls/asterisk/main.yaml b/data/ansible/calls/asterisk/main.yaml index e4ab60130..5628e2a0d 100644 --- a/data/ansible/calls/asterisk/main.yaml +++ b/data/ansible/calls/asterisk/main.yaml @@ -92,37 +92,37 @@ become: yes shell: "sudo ./configure --with-jansson-bundled" args: - chdir: '/tmp/asterisk-18.4.0' + chdir: '/tmp/asterisk-18.5.0' - name: Make Asterisk become: yes shell: "sudo make" args: - chdir: '/tmp/asterisk-18.4.0' + chdir: '/tmp/asterisk-18.5.0' - name: Make all Asterisk become: yes shell: "make all" args: - chdir: '/tmp/asterisk-18.4.0' + chdir: '/tmp/asterisk-18.5.0' - name: Make install Asterisk become: yes shell: "sudo make install" args: - chdir: '/tmp/asterisk-18.4.0' + chdir: '/tmp/asterisk-18.5.0' - name: Make samples Asterisk become: yes shell: "sudo make samples" args: - chdir: '/tmp/asterisk-18.4.0' + chdir: '/tmp/asterisk-18.5.0' - name: Make config Asterisk become: yes shell: "sudo make config" args: - chdir: '/tmp/asterisk-18.4.0' + chdir: '/tmp/asterisk-18.5.0' - name: Add user for Asterisk become: yes @@ -136,4 +136,4 @@ # Configure PJSUA - name: Config PJSUA - include: pjsua.yaml \ No newline at end of file + include: pjsua.yaml diff --git a/data/ansible/calls/freeswitch/cgrates.yaml b/data/ansible/calls/freeswitch/cgrates.yaml index 202583517..51352e385 100644 --- a/data/ansible/calls/freeswitch/cgrates.yaml +++ b/data/ansible/calls/freeswitch/cgrates.yaml @@ -32,14 +32,21 @@ dest: "/usr/share/cgrates" state: link -- name: symbol 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 mysql + +- 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: @@ -50,3 +57,20 @@ 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 }}" diff --git a/data/ansible/calls/freeswitch/main.yaml b/data/ansible/calls/freeswitch/main.yaml index 9988d8e2a..f4b087da2 100644 --- a/data/ansible/calls/freeswitch/main.yaml +++ b/data/ansible/calls/freeswitch/main.yaml @@ -44,66 +44,83 @@ remote_user: '{{ user }}' tasks: -########################################################################################################################### -# install dependencies - - name: Install dependencies - become: yes - apt: name={{ dependencies }} state=present + ########################################################################################################################### + # install dependencies + - name: Install dependencies + become: yes + apt: name={{ dependencies }} state=present - - name: Add key for freeswitch - become: yes - apt_key: url=https://files.freeswitch.org/repo/deb/debian-release/fsstretch-archive-keyring.asc state=present + - name: Add key for freeswitch + become: yes + apt_key: url=https://files.freeswitch.org/repo/deb/debian-release/fsstretch-archive-keyring.asc state=present - - name: Add FreeSwitch apt repository (1.8) (Debian 8/Jessie) - become: yes - apt_repository: - repo: deb http://files.freeswitch.org/repo/deb/debian-release/ stretch main - state: present - filename: 'freeswitch' + - name: Add FreeSwitch apt repository (1.8) (Debian 8/Jessie) + become: yes + apt_repository: + repo: deb http://files.freeswitch.org/repo/deb/debian-release/ buster main + state: present + filename: 'freeswitch' - # Install FreeSwitch - - name: Install FreeSwitch - become: yes - apt: name={{ freeswitch_packages }} state=latest + - name: Add FreeSwitch apt repository (1.8) (Debian 8/Jessie) + become: yes + apt_repository: + repo: deb-src http://files.freeswitch.org/repo/deb/debian-release/ buster main + state: present + filename: 'freeswitch' -########################################################################################################################### -# Install Golang - - name: install unarchive dependencies (zypper) - become: yes - zypper: - name: - - gzip - - tar - state: present - when: ansible_pkg_mgr == 'zypper' + # Install FreeSwitch + - name: Install FreeSwitch + become: yes + apt: name={{ freeswitch_packages }} state=latest - - name: Install golang - include: go.yaml + ########################################################################################################################### + # Install Golang + - name: install unarchive dependencies (zypper) + become: yes + zypper: + name: + - gzip + - tar + state: present + when: ansible_pkg_mgr == 'zypper' -########################################################################################################################### -# Install and config CGRateS - - name: Install and config CGRateS - include: cgrates.yaml + - name: Install golang + include: go.yaml -# Configure FreeSwitch - - 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' + ########################################################################################################################### + # Install and config CGRateS + - name: Install and config CGRateS + include: cgrates.yaml - - name: Remove FreeSWITCH default config from /etc/freesitch - become: yes - shell: 'sudo rm -rf *' - args: - chdir: '/etc/freeswitch' + # Configure FreeSwitch + - 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: Copy our custom config for FreeSWITCH in /etc/freesitch - become: yes - shell: 'sudo cp -r {{ cgrates_dir }}/data/tutorial_tests/fs_evsock/freeswitch/etc/freeswitch/* /etc/freeswitch' - args: - chdir: '/etc/freeswitch' + - 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' -# Configure PJSUA - - name: Config PJSUA - include: pjsua.yaml + - name: Remove FreeSWITCH default config from /etc/freeswitch + become: yes + shell: 'sudo rm -rf *' + args: + chdir: '/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' + + - name: Add user for CGRateS + become: yes + shell: 'sudo useradd cgrates' + + # Configure PJSUA + - name: Config PJSUA + include: pjsua.yaml diff --git a/data/ansible/calls/kamailio/cgrates.yaml b/data/ansible/calls/kamailio/cgrates.yaml index 202583517..51352e385 100644 --- a/data/ansible/calls/kamailio/cgrates.yaml +++ b/data/ansible/calls/kamailio/cgrates.yaml @@ -32,14 +32,21 @@ dest: "/usr/share/cgrates" state: link -- name: symbol 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 mysql + +- 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: @@ -50,3 +57,20 @@ 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 }}" diff --git a/data/ansible/calls/kamailio/main.yaml b/data/ansible/calls/kamailio/main.yaml index 0420619a9..dde8a413e 100644 --- a/data/ansible/calls/kamailio/main.yaml +++ b/data/ansible/calls/kamailio/main.yaml @@ -52,7 +52,7 @@ become: yes apt: name={{ dependencies }} state=present - # Install FreeSwitch + # Install Kamailio - name: Install Kamailio become: yes apt: name={{ kamailio_package }} state=latest @@ -77,6 +77,10 @@ include: cgrates.yaml + - name: Add user for CGRateS + become: yes + shell: 'sudo useradd cgrates' + # Configure PJSUA - name: Config PJSUA include: pjsua.yaml