1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-03-09 15:40:17 +00:00

Initial stab at adding a PBX. Playbooks and necessary config for Asterisk

This commit is contained in:
Anish Mangal 2019-01-17 06:47:59 +00:00 committed by root
parent 31715f1633
commit f6089d9913
10 changed files with 206 additions and 0 deletions

View file

@ -57,6 +57,12 @@
# when: owncloud_install
# tags: owncloud
- name: PBX
include_role:
name: pbx
when: pbx_install
tags: pbx
- name: WORDPRESS
include_role:
name: wordpress

View file

@ -0,0 +1,7 @@
pbx_install: False
pbx_enabled: False
pbx_installed: False
asterisk_url: http://downloads.asterisk.org/pub/telephony/asterisk/
asterisk_src_file: asterisk-16-current.tar.gz
asterisk_src_dir: /opt/iiab/asterisk

View file

@ -0,0 +1,136 @@
- name: Asterisk - Install dependencies
include: asterisk_dependencies.yml
- name: Asterisk - Download software to /opt/iiab/downloads
get_url:
url: "{{ asterisk_url }}/{{ asterisk_src_file }}"
dest: "{{ downloads_dir }}/{{ asterisk_src_file }}"
timeout: "{{ download_timeout }}"
when: internet_available
- name: Asterisk - Check for /opt/iiab/downloads/{{ asterisk_src_file }}
stat:
path: "{{ downloads_dir }}/{{ asterisk_src_file }}"
register: asterisk_src
- name: Asterisk - FAIL (force Ansible to exit) IF /opt/iiab/downloads/{{ asterisk_src_file }} doesn't exist
fail:
msg: "{ downloads_dir }}/{{ asterisk_src_file }} is REQUIRED in order to install."
when: not asterisk_src.stat.exists
- name: Asterisk - Create install source directory
file:
path: "{{ asterisk_src_dir }}"
state: directory
- name: Asterisk - Extract source
unarchive:
src: "{{ downloads_dir }}/{{ asterisk_src_file }}"
dest: "{{ asterisk_src_dir }}"
owner: root
group: root
- name: Asterisk - Download mp3 decoder library into source tree
command: "./contrib/scripts/get_mp3_source.sh"
args:
chdir: {{ asterisk_src_dir }}
creates: addons/mp3/mpg123.h
- name: Asterisk - Ensure all dependencies are resolved
shell: export DEBIAN_FRONTEND=noninteractive && ./contrib/scripts/install_prereq install
args:
chdir: {{ asterisk_src_dir }}
- name: Asterisk - Run the configure script
command: "./configure"
args:
chdir:{{ asterisk_src_dir }}
- name: Asterisk - Run make menuselect.makeopts
command: "make menuselect.makeopts"
args:
chdir:{{ asterisk_src_dir }}
- name: Asterisk - Do a bit of menuselect configuration
command: >
menuselect/menuselect --enable app_macro --enable format_mp3
--enable CORE-SOUNDS-EN-WAV --enable CORE-SOUNDS-EN-G722
--enable EXTRA-SOUNDS-EN-WAV --enable EXTRA-SOUNDS-EN-G722 --enable EXTRA-SOUNDS-EN-GSM
--disable-category MENUSELECT_MOH
args:
chdir:{{ asterisk_src_dir }}
- name: Asterisk - Run 'make'
command: make
args:
chdir:{{ asterisk_src_dir }}
- name: Asterisk - install
command: make install
args:
chdir:{{ asterisk_src_dir }}
- name: Asterisk - install config
command: make config
args:
chdir:{{ asterisk_src_dir }}
- name: Asterisk - install samples
command: make samples
args:
chdir:{{ asterisk_src_dir }}
- name: Asterisk - ldconfig
command: ldconfig
args:
chdir:{{ asterisk_src_dir }}
- name: Asterisk - Create the necessary user/group config and set permissions
command: "{{ item }} chdir={{ asterisk_src_dir }}"
with_items:
- groupadd asterisk
- useradd -r -d /var/lib/asterisk -g asterisk asterisk
- usermod -aG audio,dialout asterisk
- chown -R asterisk.asterisk /etc/asterisk
- chown -R asterisk.asterisk /var/{lib,log,spool}/asterisk
- chown -R asterisk.asterisk /usr/lib/asterisk
- name: Asterisk - Set default user to asterisk in /etc/default/asterisk
lineinfile:
path: /etc/default/asterisk
regexp: 'AST_USER='
line: 'AST_USER="asterisk"'
- name: Asterisk - Set default group to asterisk in /etc/default/asterisk
lineinfile:
path: /etc/default/asterisk
regexp: 'AST_GROUP='
line: 'AST_GROUP="asterisk"'
- name: Asterisk - Set default user to asterisk in /etc/asterisk/asterisk.conf
lineinfile:
path: /etc/asterisk/asterisk.conf
regexp: 'runuser ='
line: 'runuser = asterisk'
- name: Asterisk - Set default group to asterisk in /etc/asterisk/asterisk.conf
lineinfile:
path: /etc/asterisk/asterisk.conf
regexp: 'rungroup ='
line: 'rungroup = asterisk'
- name: Enable & Start asterisk service
systemd:
daemon_reload: yes
name: asterisk
enabled: yes
state: started
when: asterisk_enabled
- name: Disable & Stop asterisk service
systemd:
daemon_reload: yes
name: asterisk
enabled: no
state: stopped
when: (not asterisk_enabled)

View file

@ -0,0 +1,16 @@
- name: Install asterisk dependencies
package:
name:
- git
- curl
- wget
- libnewt-dev
- libssl-dev
- libncurses5-dev
- subversion
- libsqlite3-dev
- build-essential
- libjansson-dev
- libxml2-dev
- uuid-dev
state: latest

View file

9
roles/pbx/tasks/main.yml Normal file
View file

@ -0,0 +1,9 @@
#- name: TODO: Check if asterisk and freepbx are already installed
- name: Install asterisk
include_tasks: asterisk.yml
when: internet_available and is_ubuntu_18 and pbx_install and (not pbx_installed)
- name: Install freepbx
include_tasks: freepbx.yml
when: internet_available and is_ubuntu_18 and pbx_install and (not pbx_installed)

View file

@ -296,6 +296,14 @@ nodered_port: 1880
nextcloud_install: False
nextcloud_enabled: False
# A full featured PBX based on Asterisk and FreePBX
#
# Caution!
# This is a LARGE install that will compile from source and take lots of time. Handle with care!
# So far, supported on Ubuntu 18.x ONLY.
pbx_install: False
pbx_enabled: False
# If using WordPress intensively, set apache_high_php_limits in 3-BASE-SERVER
wordpress_install: False
wordpress_enabled: False

View file

@ -195,6 +195,14 @@ nodered_enabled: True
nextcloud_install: True
nextcloud_enabled: True
# A full featured PBX based on Asterisk and FreePBX
#
# Caution!
# This is a LARGE install that will compile from source and take lots of time. Handle with care!
# So far, supported on Ubuntu 18.x ONLY.
pbx_install: True
pbx_enabled: True
# If using WordPress intensively, set apache_high_php_limits in 3-BASE-SERVER
wordpress_install: True
wordpress_enabled: True

View file

@ -195,6 +195,14 @@ nodered_enabled: False
nextcloud_install: True
nextcloud_enabled: True
# A full featured PBX based on Asterisk and FreePBX
#
# Caution!
# This is a LARGE install that will compile from source and take lots of time. Handle with care!
# So far, supported on Ubuntu 18.x ONLY.
pbx_install: False
pbx_enabled: False
# If using WordPress intensively, set apache_high_php_limits in 3-BASE-SERVER
wordpress_install: True
wordpress_enabled: True

View file

@ -195,6 +195,14 @@ nodered_enabled: False
nextcloud_install: False
nextcloud_enabled: False
# A full featured PBX based on Asterisk and FreePBX
#
# Caution!
# This is a LARGE install that will compile from source and take lots of time. Handle with care!
# So far, supported on Ubuntu 18.x ONLY.
pbx_install: False
pbx_enabled: False
# If using WordPress intensively, set apache_high_php_limits in 3-BASE-SERVER
wordpress_install: False
wordpress_enabled: False