Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update os, asterisk, freepbx #1

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cloudpbx-freepbx.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
## Deploy Cloud PBX Freepbx ####
## Updated to work on Ubuntu Server 20.04 and 22.04###
## Supports Ubuntu 24.x (minimal)
---
-
name: Depoying CloudPBX Freepbx
hosts: all
become: true
vars:
db_root_pass: "{{ lookup('env','DB_ROOT_PASS') }}"
fpbx_ver: 16.0
ast_ver: 20
fpbx_ver: 17.0
ast_ver: 21
nodejs_ver: 18
roles:
- sysprep
- db_prep
Expand Down
2 changes: 2 additions & 0 deletions freepbx-hosts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[fpbx]
fpbx01 ansible_connection=ssh ansible_host=<host ip> ansible_ssh_pass=<ssh root pass> ansible_user=root
196 changes: 85 additions & 111 deletions roles/asterisk/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,133 +1,112 @@
---
- name: Download Asterisk {{ ast_ver }}
ansible.builtin.get_url:
url: http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-{{ ast_ver }}-current.tar.gz
-
name: Download Asterisk {{ast_ver}}
get_url:
url: http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-{{ast_ver}}-current.tar.gz
dest: /usr/src
mode: '0664'

- name: Untar Asterisk tarball
ansible.builtin.unarchive:
src: /usr/src/asterisk-{{ ast_ver }}-current.tar.gz
-
name: Untar Asterisk tarball
unarchive:
src: /usr/src/asterisk-{{ast_ver}}-current.tar.gz
dest: /usr/src
remote_src: true

- name: Remove Asterisk tarball
ansible.builtin.file:
path: /usr/src/asterisk-{{ ast_ver }}-current.tar.gz
remote_src: yes
-
name: Remove Asterisk tarball
file:
path: /usr/src/asterisk-{{ast_ver}}-current.tar.gz
state: absent

- name: Find extracted folder name for Asterisk {{ ast_ver }}
ansible.builtin.find:
-
name: "Find extracted Asterisk {{ast_ver}} folder name "
find:
paths: /usr/src
file_type: directory
recurse: false
recurse: no
patterns: ^asterisk.*$
use_regex: true
use_regex: yes
register: 'ast_install_dir'

- name: Make Libvpb1 install non-interactive
ansible.builtin.shell:
cmd: "{{ item }}"
creates: libvpb1.ok
executable: /bin/bash
with_items:
- set -o pipefail
- echo 'libvpb1 libvpb1/countrycode string 381' | sudo debconf-set-selections -v
- touch libvpb1.ok

- name: Install Asterisk Prerequisites
ansible.builtin.shell:
cmd: "{{ item }}"
chdir: "{{ ast_install_dir.files[0].path }}/contrib/scripts"
creates: asterisk-prereq.ok
executable: /bin/bash
-
name: "Make Libvpb1 install non-interactive"
shell: set -o pipefail | echo 'libvpb1 libvpb1/countrycode string 381' | sudo debconf-set-selections -v
-
name: Install Asterisk Prereqisites
shell:
cmd: "{{item}}"
chdir: "{{ast_install_dir.files[0].path}}/contrib/scripts"
with_items:
- ./get_mp3_source.sh
- ./install_prereq install
- touch asterisk-prereq.ok

- name: Run configure asterisk scripts
ansible.builtin.shell:
cmd: "{{ item }}"
chdir: "{{ ast_install_dir.files[0].path }}"
creates: ast-scripts.ok
executable: /bin/bash
with_items:
- ./configure --with-pjproject-bundled --with-jansson-bundled
- touch ast-scripts.ok

- name: Select make options
ansible.builtin.shell:
cmd: "{{ item }}"
chdir: "{{ ast_install_dir.files[0].path }}"
creates: ast-make-menu.ok
executable: /bin/bash
-
name: Run configure asterisk scripts
shell:
cmd: ./configure --with-pjproject-bundled --with-jansson-bundled
chdir: "{{ast_install_dir.files[0].path}}"
-
name: Select make options
shell:
cmd: "{{item}}"
chdir: "{{ast_install_dir.files[0].path}}"
with_items:
- make menuselect.makeopts
- menuselect/menuselect --enable app_macro --enable format_mp3 menuselect.makeopts
- touch ast-make-menu.ok

- name: Compile and Install Asterisk
ansible.builtin.shell:
cmd: "{{ item }}"
chdir: "{{ ast_install_dir.files[0].path }}"
creates: compiled-asterisk.ok
executable: /bin/bash
- menuselect/menuselect --enable res_config_mysql --enable format_mp3 menuselect.makeopts
-
name: Compile and Install Asterisk
shell:
cmd: "{{item}}"
chdir: "{{ast_install_dir.files[0].path}}"
with_items:
- make
- contrib/scripts/get_mp3_source.sh
- make install
- make config
- ldconfig
- update-rc.d -f asterisk remove
- touch compiled-asterisk.ok

- name: Add asterisk users
ansible.builtin.user:
-
name: Add asterisk users
user:
name: asterisk
comment: Asterisk user

- name: Seting folder permitions for asterisk user
ansible.builtin.file:
path: "{{ item }}"
-
name: Seting folder permitions for asterisk user
file:
path: "{{item}}"
owner: asterisk
group: asterisk
state: directory
recurse: true
recurse: yes
with_items:
- /var/run/asterisk
- /etc/asterisk
- /var/lib/asterisk
- /var/log/asterisk
- /var/spool/asterisk
- /usr/lib/asterisk

- name: Remove default web folder
ansible.builtin.file:
-
name: Remove default web folder
file:
path: /var/www/html
state: absent

- name: Find php version folder name
ansible.builtin.find:
-
name: "Find php version folder name "
find:
paths: /etc/php
file_type: directory
recurse: false
patterns: ^7.*$
use_regex: true
recurse: no
patterns: ^8.*$
use_regex: yes
register: 'php_ver'

- name: Making some Apache config changes
ansible.builtin.lineinfile:
path: "{{ item.path }}"
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
-
name: Making some Apache config changes
lineinfile:
path: "{{item.path}}"
regexp: "{{item.regexp}}"
line: "{{item.line}}"
with_items:
-
path: "{{ php_ver.files[0].path }}/apache2/php.ini"
path: "{{php_ver.files[0].path}}/apache2/php.ini"
regexp: "upload_max_filesize ="
line: "upload_max_filesize = 20M"
-
path: "{{ php_ver.files[0].path }}/apache2/php.ini"
path: "{{php_ver.files[0].path}}/apache2/php.ini"
regexp: "memory_limit ="
line: "memory_limit = 256M"
-
Expand All @@ -138,34 +117,29 @@
path: /etc/apache2/envvars
regexp: export APACHE_RUN_GROUP=
line: export APACHE_RUN_GROUP=asterisk

- name: Some more Apache changes
ansible.builtin.replace:
-
name: Some more Apache changes
replace:
path: '/etc/apache2/apache2.conf'
regexp: 'AllowOverride None'
replace: 'AllowOverride All'

- name: Enable Apache Rewrite Mod
ansible.builtin.shell:
cmd: "{{ item }}"
creates: apache-rewrite.ok
executable: /bin/bash
with_items:
- a2enmod rewrite
- touch apache-rewrite.ok

- name: Restarting Apache Service
ansible.builtin.service:
-
name: Enable Apache Rewrite Mod
shell: a2enmod rewrite
-
name: Restarting Apache Service
service:
name: apache2
state: restarted

- name: Seting ODBC files
ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: '0664'
-
name: Seting ODBC files
template:
src: "{{item.src}}"
dest: "{{item.dest}}"
with_items:
- src: odbc.ini.j2
-
src: odbc.ini.j2
dest: /etc/odbc.ini
- src: odbcinst.ini.j2
-
src: odbcinst.ini.j2
dest: /etc/odbcinst.ini
89 changes: 40 additions & 49 deletions roles/freepbx/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,41 @@
---
- name: Downloading FreePBX {{ fpbx_ver }}
ansible.builtin.get_url:
url: http://mirror.freepbx.org/modules/packages/freepbx/freepbx-{{ fpbx_ver }}-latest.tgz
-
name: Downloading FreePBX {{fpbx_ver}}
get_url:
url: http://mirror.freepbx.org/modules/packages/freepbx/freepbx-{{fpbx_ver}}-latest.tgz
dest: /usr/src
mode: '0664'

- name: Unpacking FreePBX tarball
ansible.builtin.unarchive:
src: /usr/src/freepbx-{{ fpbx_ver }}-latest.tgz
-
name: Unpacking FreePBX tarball
unarchive:
src: /usr/src/freepbx-{{fpbx_ver}}-latest.tgz
dest: /usr/src
remote_src: true

- name: Removing FreePBX tarball
ansible.builtin.file:
path: /usr/src/freepbx-{{ fpbx_ver }}-latest.tgz
remote_src: yes
-
name: Removing FreePBX tarball
file:
path: /usr/src/freepbx-{{fpbx_ver}}-latest.tgz
state: absent

- name: Creating some asterisk files
ansible.builtin.file:
path: /etc/asterisk/{{ item }}.conf
-
name: Creating some asterisk files
file:
path: /etc/asterisk/{{item}}.conf
state: touch
mode: '0664'
with_items:
- modules
- cdr

- name: Starting FreePBX
ansible.builtin.shell:
cmd: "{{ item }}"
-
name: Starting FreePBX
shell:
cmd: "{{item}}"
chdir: /usr/src/freepbx
creates: start-fpbx.ok
executable: /bin/bash
no_log: false
with_items:
- ./start_asterisk start
- ./install -n --dbuser root --dbpass {{ db_root_pass }}
- touch start-fpbx.ok

- name: Install FreePBX Modules
ansible.builtin.shell: "{{ item }}"
args:
creates: fpbx-started.ok
executable: /bin/bash
- ./install -n --dbuser root --dbpass {{db_root_pass}}
# freepbx install script returns code 1 for successfull install
ignore_errors: true
-
name: Install FPBX Modules
shell: "{{item}}"
with_items:
- fwconsole ma enablerepo standard
- fwconsole ma enablerepo extended
Expand All @@ -60,25 +54,22 @@
- fwconsole ma downloadinstall outroutemsg
- fwconsole ma downloadinstall timeconditions
- fwconsole ma downloadinstall queues
- fwconsole ma upgradeall
- fwconsole reload
- fwconsole restart
- touch fpbx-started.ok

- name: Create FreePBX Startup service
ansible.builtin.template:
-
name: Create FreePBX Startup service
template:
src: freepbx.service.j2
dest: /etc/systemd/system/freepbx.service
mode: '0664'

- name: Enable FreePBX Service
ansible.builtin.service:
-
name: Enable FreePBX Service
service:
name: freepbx.service
enabled: true

- name: Set hostname
ansible.builtin.hostname:
enabled: yes
-
name: Set hostname
hostname:
name: fpbx.local

- name: Reboot host
ansible.builtin.reboot:
-
name: Reboot host
reboot:
Loading