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

Branch pbx2 experimentation / preparation

This commit is contained in:
root 2021-08-04 23:14:24 -04:00
parent a7a296f5fe
commit 85105bad7c
7 changed files with 98 additions and 93 deletions

View file

@ -48,8 +48,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 }}"
@ -108,7 +107,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 +116,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,41 +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!
#
# Adding 'RestartSec=3' to freepbx.service is not the answer. Discussion here:
# https://github.com/iiab/iiab/pull/2908
#
#- 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
@ -52,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,6 @@
# 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/
- name: FreePBX - Install dependencies
include: freepbx_dependencies.yml
@ -45,12 +48,13 @@
# 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
- name: FreePBX - Add MySQL user ({{ asterisk_db_user }})
mysql_user:
@ -81,17 +85,6 @@
login_host: "{{ asterisk_db_host }}"
state: present
- name: FreePBX - Prevent /etc/asterisk/freepbx_chown.conf takeover 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/
file:
path: /var/lib/php/asterisk_sessions/
@ -104,15 +97,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 +114,45 @@
# src: roles/pbx/templates/pbx2.patch
# dest: "{{ freepbx_install_dir }}/admin/libraries/view.functions.php"
- name: FreePBX - 2-step 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 }}
# - ./start_asterisk stop # Can this help Asterisk start reliably on initial install on Debian 11 / others? #2908
# - 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)
template:
src: odbc.ini.j2
dest: /etc/odbc.ini
src: odbc.ini
dest: /etc/
- name: FreePBX - Install /etc/systemd/system/freepbx.service systemd unit file from template (root:root, 0644 by default)
- name: FreePBX - Install /etc/systemd/system/freepbx.service from template (root:root, 0644 by default)
template:
src: freepbx.service.j2
dest: /etc/systemd/system/freepbx.service
src: freepbx.service
dest: /etc/systemd/system/
- 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

@ -0,0 +1,15 @@
[Unit]
Description=FreePBX VoIP Server
After=mysql.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/fwconsole start
ExecStop=/usr/sbin/fwconsole stop
# 2021-08-04: Asterisk doesn't (re)start reliably, as FreePBX install completes:
# https://github.com/iiab/iiab/blob/master/roles/pbx/tasks/enable-or-disable.yml
# RestartSec=3
[Install]
WantedBy=multi-user.target

View file

@ -7,9 +7,8 @@ Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/fwconsole start
ExecStop=/usr/sbin/fwconsole stop
# 2021-08-04: Asterisk doesn't (re)start reliably, as FreePBX install completes:
# 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