1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-12 19:22:24 +00:00

Merge branch 'iiab:master' into less-apache

This commit is contained in:
A Holt 2021-08-06 07:27:53 -04:00 committed by GitHub
commit a189c6a894
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 126 additions and 104 deletions

View file

@ -15,11 +15,11 @@
# All above are set in: github.com/iiab/iiab/blob/master/vars/default_vars.yml
# If nec, change them by editing /etc/iiab/local_vars.yml prior to installing!
asterisk_url: http://downloads.asterisk.org/pub/telephony/asterisk/
asterisk_url: http://downloads.asterisk.org/pub/telephony/asterisk
asterisk_src_file: asterisk-18-current.tar.gz
asterisk_src_dir: /opt/iiab/asterisk
freepbx_url: http://mirror.freepbx.org/modules/packages/freepbx/7.4/
freepbx_url: http://mirror.freepbx.org/modules/packages/freepbx/7.4
freepbx_src_file: freepbx-16.0-latest.tgz # Beta as of 2021-06-21 but looking great! Does NOT support PHP < 7.4 (you've been warned!) Please review https://github.com/iiab/iiab/blob/master/roles/pbx/README.rst
freepbx_src_dir: /opt/iiab/freepbx
freepbx_install_dir: /var/www/html/freepbx
@ -30,6 +30,6 @@ asterisk_db_dbname: asterisk
asterisk_db_password: asterisk
asterisk_db_cdrdbname: asteriskcdrdb
chan_dongle_url: https://github.com/wdoekes/asterisk-chan-dongle/archive/
chan_dongle_url: https://github.com/wdoekes/asterisk-chan-dongle/archive
chan_dongle_src_file: master.zip
chan_dongle_src_dir: /opt/iiab/chan_dongle

View file

@ -1,7 +1,16 @@
# 2021-08-03: Asterisk's own install_prereq (below) handles these?
# 2021-08-05: Asterisk's own install_prereq (below) handles essentially all of these
#- name: Asterisk - Install dependencies
# include: asterisk_dependencies.yml
# BEWARE: 'systemctl is-active asterix' falsely reports 'inactive' even when systemd
# is compiled in below! FWIW: /opt/iiab/asterisk/contrib/systemd/asterisk.service
# https://github.com/asterisk/asterisk/blob/master/contrib/systemd/asterisk.service
- name: Asterisk - Install package 'libsystemd-dev' so Asterisk compiles in imperfect-but-improving systemd support -- if ./configure below places '#define HAVE_SYSTEMD 1' in /opt/iiab/asterisk/include/asterisk/autoconfig.h -- please later confirm with 'ldd /usr/sbin/asterisk | grep systemd' -- per https://community.asterisk.org/t/systemctl-start-asterisk-is-fail-with-timeout/81123/3
package:
name: libsystemd-dev
state: present
- name: Asterisk - Download {{ asterisk_url }}/{{ asterisk_src_file }} to {{ downloads_dir }}
get_url:
url: "{{ asterisk_url }}/{{ asterisk_src_file }}"
@ -48,8 +57,7 @@
args:
chdir: "{{ asterisk_src_dir }}"
# 2021-08-03: Requires subversion (installed just above)
- name: Asterisk - Download mp3 decoder library into source tree
- name: Asterisk - Download mp3 decoder library into source tree - requires 'subversion' installed just above
command: ./contrib/scripts/get_mp3_source.sh
args:
chdir: "{{ asterisk_src_dir }}"
@ -75,7 +83,7 @@
args:
chdir: "{{ asterisk_src_dir }}"
- name: Asterisk - Run 'make' - CAN TAKE 30 MIN OR LONGER!
- name: Asterisk - Run 'make' - CAN TAKE 8-30 MIN OR LONGER!
command: make
args:
chdir: "{{ asterisk_src_dir }}"
@ -98,7 +106,7 @@
chdir: "{{ asterisk_src_dir }}"
- name: Asterisk - Run 'ldconfig'
shell: ldconfig
command: ldconfig
args:
chdir: "{{ asterisk_src_dir }}"
@ -108,7 +116,7 @@
name: asterisk
state: present
- name: "Asterisk - Ensure user 'asterisk' exists, and belongs to groups: audio,dialout"
- name: Asterisk - Ensure system user 'asterisk' has primary group 'asterisk', groups 'audio,dialout', home '/var/lib/asterisk'
user:
name: asterisk
group: asterisk
@ -117,7 +125,7 @@
system: yes
append: yes
- name: "Asterisk - Set ownership (asterisk:asterisk) for 5 directories: /etc/asterisk, /var/lib/asterisk, /var/log/asterisk, /var/spool/asterisk, /usr/lib/asterisk"
- name: Asterisk - Set ownership for 5 directories (asterisk:asterisk, recurse)
file:
dest: "{{ item }}"
owner: asterisk

View file

@ -1,12 +1,12 @@
- name: Asterisk - Install dependencies
package:
name:
- git
- curl
- git # 2021-08-05: Not in Asterisk's install_prereq
- curl # 2021-08-05: Not in Asterisk's install_prereq
- wget
- libnewt-dev
- libssl-dev
- libncurses5-dev
- libncurses5-dev # 2021-08-05: Not in Asterisk's install_prereq
- subversion
- libsqlite3-dev
- build-essential

View file

@ -1,3 +1,5 @@
# RPi: http://mghadam.blogspot.com/2021/03/install-asterisk-18-freepbx-15-on.html
- name: chan_dongle - Download {{ chan_dongle_url }}/{{ chan_dongle_src_file }} to {{ downloads_dir }}
get_url:
url: "{{ chan_dongle_url }}/{{ chan_dongle_src_file }}" # /opt/iiab/downloads/master.zip

View file

@ -1,40 +1,14 @@
# 2021-08-04: Stanza below commonly causes systemd error "Asterisk is already
# running. /etc/init.d/asterisk will exit now" (initial installs especially?)
#
# But without this stanza, 'systemctl restart freepbx' all alone during initial
# install ALSO fails to start Asterisk reliably, on Ubuntu 20.04 & Debian 11 :/
#
# Yes /etc/systemd/system/freepbx.service is supposed to run 'fwconsole stop'
# then 'fwconsole start' reliably, as many web posts recommend, But No Dice!
#
# Do we need something like 'RestartSec=3' in freepbx.service ??
#
#- name: Enable & (Re)start 'asterisk' systemd service (if pbx_enabled)
# systemd:
# daemon_reload: yes
# name: asterisk
# enabled: yes
# state: restarted
# when: pbx_enabled
#- name: Disable & Stop 'asterisk' systemd service (if not pbx_enabled)
# systemd:
# daemon_reload: yes
# name: asterisk
# enabled: no
# state: stopped
# when: not pbx_enabled
- name: Enable & (Re)start 'freepbx' systemd service (if pbx_enabled)
- name: Enable & (Re)start 'freepbx' systemd service, if pbx_enabled
systemd:
daemon_reload: yes
name: freepbx
enabled: yes
state: restarted
when: pbx_enabled
- name: Disable & Stop 'freepbx' systemd service (if not pbx_enabled)
- name: Disable & Stop 'freepbx' systemd service, if not pbx_enabled
systemd:
daemon_reload: yes
name: freepbx
enabled: no
state: stopped
@ -51,5 +25,23 @@
- name: Restart Apache service ({{ apache_service }})
systemd:
name: "{{ apache_service }}" # httpd or apache2
name: "{{ apache_service }}" # apache2
state: restarted
# - name: Enable http://box/freepbx via NGINX, by installing {{ nginx_conf_dir }}/freepbx-nginx.conf from template
# template:
# src: freepbx-nginx.conf.j2
# dest: "{{ nginx_conf_dir }}/freepbx-nginx.conf" # /etc/nginx/conf.d
# when: pbx_enabled
# - name: Disable http://box/freepbx via NGINX, by removing {{ nginx_conf_dir }}/freepbx-nginx.conf
# file:
# path: "{{ nginx_conf_dir }}/freepbx-nginx.conf"
# state: absent
# when: not pbx_enabled
# - name: Restart 'nginx' systemd service
# systemd:
# name: nginx
# state: restarted

View file

@ -1,3 +1,8 @@
# https://wiki.freepbx.org/display/FOP/Installing+FreePBX+16+on+Debian+10.9
# https://computingforgeeks.com/how-to-install-asterisk-16-with-freepbx-15-on-ubuntu-debian/
# RPi: http://mghadam.blogspot.com/2021/03/install-asterisk-18-freepbx-15-on.html
# 2012-2017: http://www.raspberry-asterisk.org
- name: FreePBX - Install dependencies
include: freepbx_dependencies.yml
@ -45,12 +50,21 @@
# dest: "{{ freepbx_src_dir }}/amp_conf/htdocs/admin/libraries/Composer/vendor/neitanod/forceutf8/src/ForceUTF8/Encoding.php"
- name: FreePBX - Disable & Stop 'asterisk' systemd service
systemd:
daemon_reload: yes
name: asterisk
enabled: no
state: stopped
# 2021-08-04: systemd service 'asterisk' is Enabled but Not Active at this point -- LET'S EXPERIMENT
# - name: FreePBX - Disable & Stop 'asterisk' systemd service
# systemd:
# daemon_reload: yes
# name: asterisk
# enabled: no
# state: stopped
# 2021-08-05: Asterisk's systemd / systemctl support is getting there but Very
# Imperfect (even when compiled in, as a result of package 'libsystemd-dev' at
# top of asterisk.tml) so let's follow these "official" instructions for now:
- name: FreePBX - Run 'update-rc.d -f asterisk remove' similar to 'systemctl disable asterisk' giving FreePBX full control during boot - not strictly required but recommended by https://wiki.freepbx.org/display/FOP/Installing+FreePBX+16+on+Debian+10.9
command: update-rc.d -f asterisk remove
- name: FreePBX - Add MySQL user ({{ asterisk_db_user }})
mysql_user:
@ -81,18 +95,7 @@
login_host: "{{ asterisk_db_host }}"
state: present
- name: FreePBX - Prevent /etc/asterisk/freepbx_chown.conf take over of /var/lib/php/sessions
blockinfile:
content: |
[blacklist]
directory = /var/lib/php/sessions
marker: "; {mark} ANSIBLE MANAGED BLOCK"
dest: /etc/asterisk/freepbx_chown.conf
owner: asterisk
group: asterisk
create: yes
- name: FreePBX - Create new php sessions dir /var/lib/php/asterisk_sessions/
- name: FreePBX - Create new php sessions dir /var/lib/php/asterisk_sessions/ - SEE 'php_value session.save_path /var/lib/php/asterisk_sessions/' IN pbx/templates/freepbx.conf.j2
file:
path: /var/lib/php/asterisk_sessions/
state: directory
@ -104,15 +107,16 @@
group: asterisk
recurse: yes
- name: FreePBX - 2-stage install (just run once) - CAN TAKE 12 MIN OR LONGER!
command: "{{ item }}"
args:
chdir: "{{ freepbx_src_dir }}"
creates: "{{ freepbx_install_dir }}"
with_items:
- ./start_asterisk start
- ./install -n --webroot {{ freepbx_install_dir }} --dbuser {{ asterisk_db_user }} --dbpass {{ asterisk_db_password }} --dbname {{ asterisk_db_dbname }} --cdrdbname {{ asterisk_db_cdrdbname }}
- name: "FreePBX - Populate /etc/asterisk/freepbx_chown.conf to prevent 'fwconsole chown' takeover of /var/lib/php/sessions - and possibly later /etc/freepbx.conf, /var/log/asterisk/freepbx.log, /var/spool/asterisk/cache"
blockinfile:
content: |
[blacklist]
directory = /var/lib/php/sessions
marker: "; {mark} ANSIBLE MANAGED BLOCK"
dest: /etc/asterisk/freepbx_chown.conf
owner: asterisk
group: asterisk
create: yes
# 2021-08-04: FreePBX 16 no longer needs this FreePBX 15 patch
# - name: FreePBX - Patch FreePBX source - disable get_magic_quotes_gpc()
@ -120,15 +124,55 @@
# src: roles/pbx/templates/pbx2.patch
# dest: "{{ freepbx_install_dir }}/admin/libraries/view.functions.php"
- name: FreePBX - Install /etc/odbc.ini from template (root:root, 0644 by default)
template:
src: odbc.ini.j2
dest: /etc/odbc.ini
- name: FreePBX - Install /etc/systemd/system/freepbx.service systemd unit file from template (root:root, 0644 by default)
- name: FreePBX - 2-step install (just run once) - CAN TAKE 3-12 MIN OR LONGER!
command: "{{ item }}"
args:
chdir: "{{ freepbx_src_dir }}"
creates: "{{ freepbx_install_dir }}" # /var/www/html/freepbx
with_items:
- ./start_asterisk start
- ./install -n --webroot {{ freepbx_install_dir }} --dbuser {{ asterisk_db_user }} --dbpass {{ asterisk_db_password }} --dbname {{ asterisk_db_dbname }} --cdrdbname {{ asterisk_db_cdrdbname }}
# - ./start_asterisk stop
# - killall -9 safe_asterisk # 2021-08-05: These 2 lines from PR #2912 attempted a brute force (not enough!) workaround for the #2908 annoyance on 1st
# - killall -9 asterisk # install, of 'systemctl status freepbx' showing "Unable to run Pre-Asterisk hooks, because Asterisk is already running"
# - /usr/sbin/asterisk -rx "core stop gracefully"
# - name: 'FreePBX - fix file permissions for NGINX: /etc/freepbx.conf (0644), /var/log/asterisk/freepbx.log (0666)'
# file:
# #state: file
# path: "{{ item.path }}"
# mode: "{{ item.mode }}"
# with_items:
# - { path: '/etc/freepbx.conf', mode: u=rw,g=r,o=r } # 2021-08-04: LATER ENDS UP AS 0660
# - { path: '/var/log/asterisk/freepbx.log', mode: u=rw,g=rw,o=rw } # 2021-08-04: LATER ENDS UP AS 0664
# - name: 'FreePBX - fix dir permissions for NGINX: /var/spool/asterisk/cache (0777)'
# file:
# state: directory
# path: "{{ item }}"
# mode: u=rwx,g=rwx,o=rwx # 2021-08-04: MOST CONTENT THEREIN ENDS UP AS asterisk:asterisk 664 (files) & 775 (dirs)
# # recurse: yes # Probably Doesn't Help?
# with_items:
# # - /var/www/html/freepbx/admin/assets/less/cache
# - /var/spool/asterisk/cache
- name: FreePBX - Install /etc/odbc.ini from template (root:root, 0644 by default) - in future consider compiling ODBC driver for aarch64 per http://mghadam.blogspot.com/2021/03/install-asterisk-18-freepbx-15-on.html ?
template:
src: freepbx.service.j2
dest: /etc/systemd/system/freepbx.service
src: odbc.ini
dest: /etc/
- name: FreePBX - Install /etc/systemd/system/freepbx.service from template (root:root, 0644 by default)
template:
src: freepbx.service
dest: /etc/systemd/system/
- name: FreePBX - Run 'systemctl restart freepbx' TWICE (THIS IS 1 OF 2) to get past 'systemctl status freepbx' glitch "Unable to run Pre-Asterisk hooks, because Asterisk is already running"
systemd:
daemon_reload: yes
name: freepbx
enabled: yes
state: restarted
- name: FreePBX - Install /etc/apache2/sites-available/freepbx.conf from template ({{ apache_user }}:{{ apache_user }}, 0644 by default)

View file

@ -32,34 +32,11 @@
name: httpd
# 2021-07-27: Taken care of by main.yml
#- name: TODO: Check if asterisk and freepbx are already installed
#
#- name: Check if /etc/systemd/system/freepbx.service is already installed
# stat:
# path: /etc/systemd/system/freepbx.service
# register: freepbx_installed
#
#- debug:
# msg: >-
# FreePBX already installed. Reinstall shall be skipped
# when: freepbx_installed.stat.exists
# 2021-08-03: Taken care of by asterisk.yml's scripts/install_prereq
#- name: Install 'make' package
# package:
# name: make
# state: present
- name: Install Asterisk
include_tasks: asterisk.yml
#when: internet_available and pbx_install and (pbx_installed is undefined) and is_debuntu and (not freepbx_installed.stat.exists)
#when: internet_available and pbx_install and (not pbx_installed) and ((is_debian and ansible_distribution_major_version == "9") or is_ubuntu_18)
- name: Install FreePBX
include_tasks: freepbx.yml
#when: internet_available and pbx_install and (pbx_installed is undefined) and is_debuntu and (not freepbx_installed.stat.exists)
#when: internet_available and pbx_install and (not pbx_installed) and ((is_debian and ansible_distribution_major_version == "9") or is_ubuntu_18)
# RECORD PBX AS INSTALLED

View file

@ -7,9 +7,8 @@ Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/fwconsole start
ExecStop=/usr/sbin/fwconsole stop
# 2021-08-04: Does this help Asterisk (re)start reliably, as FreePBX install completes?
# PR #2908: https://github.com/iiab/iiab/blob/master/roles/pbx/tasks/enable-or-disable.yml
RestartSec=3
# 2021-08-04: Asterisk doesn't (re)start reliably, as FreePBX install completes,
# especially on Debian 11? https://github.com/iiab/iiab/pull/2908 / PR #2910
[Install]
WantedBy=multi-user.target