1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 11:42:08 +00:00
iiab/roles/pbx/tasks/asterisk.yml

190 lines
7 KiB
YAML
Raw Normal View History

# 2022-05-25 README.adoc, with screenshots:
# https://github.com/iiab/iiab/tree/master/roles/pbx#readme
2021-08-17 00:55:56 +00:00
# 2021-08-05: Asterisk's own install_prereq (below) handles essentially all of these
2021-08-08 04:40:06 +00:00
# - name: Asterisk - Install dependencies
# include_tasks: 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 }}"
dest: "{{ downloads_dir }}" # e.g. /opt/iiab/downloads/asterisk-18-current.tar.gz
timeout: "{{ download_timeout }}"
- name: Asterisk - Check for {{ downloads_dir }}/{{ asterisk_src_file }}
stat:
path: "{{ downloads_dir }}/{{ asterisk_src_file }}"
register: asterisk_src
- name: Asterisk - FAIL (force Ansible to exit) IF {{ downloads_dir }}/{{ asterisk_src_file }} doesn't exist
fail:
msg: "{{ downloads_dir }}/{{ asterisk_src_file }} is REQUIRED to install Asterisk."
when: not asterisk_src.stat.exists
- name: Asterisk - Create source dir {{ asterisk_src_dir }}
file:
path: "{{ asterisk_src_dir }}" # /opt/iiab/asterisk
state: directory
2021-08-06 23:54:26 +00:00
- name: Asterisk - Extract to source dir (root:root by default)
unarchive:
src: "{{ downloads_dir }}/{{ asterisk_src_file }}"
dest: "{{ asterisk_src_dir }}"
2021-08-06 23:54:26 +00:00
# owner: root
# group: root
2019-01-17 08:34:29 +00:00
extra_opts: [--strip-components=1]
2019-01-18 16:53:42 +00:00
creates: "{{ asterisk_src_dir }}/Makefile"
2021-08-03 21:09:58 +00:00
# 2021-08-03: Asterisk's install_prereq script (stanza just below) installs
# 'aptitude' regardless, within handle_debian() here:
# https://github.com/asterisk/asterisk/blob/master/contrib/scripts/install_prereq#L262-L271
#
2021-08-08 04:40:06 +00:00
# - name: Asterisk - Install aptitude (otherwise install_prereq fails?)
# package:
# name: aptitude
# state: latest
2023-04-02 06:27:00 +00:00
# https://github.com/iiab/iiab/issues/3489
2023-04-02 11:09:09 +00:00
- name: Asterisk - Apply patch to {{ asterisk_src_dir }}/contrib/scripts/install_prereq for 3489
2023-04-02 06:27:00 +00:00
ansible.posix.patch:
src: install_prereq.diff
dest: "{{ asterisk_src_dir }}/contrib/scripts/install_prereq"
- name: Asterisk - Run 'install_prereq install' for dependencies - CAN TAKE 2-5 MIN OR LONGER!
shell: export DEBIAN_FRONTEND=noninteractive && ./contrib/scripts/install_prereq install
args:
2019-01-17 08:27:14 +00:00
chdir: "{{ asterisk_src_dir }}"
- name: Asterisk - Download mp3 decoder library into source tree - requires 'subversion' installed just above
2021-08-03 21:09:58 +00:00
command: ./contrib/scripts/get_mp3_source.sh
args:
chdir: "{{ asterisk_src_dir }}"
creates: addons/mp3/mpg123.h
2021-08-06 23:54:26 +00:00
- name: Asterisk - Run './configure --with-pjproject-bundled --with-jansson-bundled'
command: ./configure --with-pjproject-bundled --with-jansson-bundled
args:
2019-01-18 16:53:42 +00:00
chdir: "{{ asterisk_src_dir }}"
- name: Asterisk - Run 'make menuselect.makeopts'
command: make menuselect.makeopts
args:
2019-01-17 08:27:14 +00:00
chdir: "{{ asterisk_src_dir }}"
creates: menuselect.makeopts
- name: Asterisk - Do a bit of menuselect configuration
2021-08-06 23:54:26 +00:00
command: menuselect/menuselect --enable app_macro --enable format_mp3 menuselect.makeopts
# 2021-08-06: Let's standardize (ABOVE) if 6 others (BELOW) aren't needed?
2021-08-06 23:54:26 +00:00
# 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:
2019-01-17 08:27:14 +00:00
chdir: "{{ asterisk_src_dir }}"
- name: Asterisk - Run 'make' - CAN TAKE 4-30 MIN OR LONGER!
command: make
args:
2019-01-17 08:27:14 +00:00
chdir: "{{ asterisk_src_dir }}"
creates: defaults.h
- name: Asterisk - Run 'make install' - CAN TAKE 1-2 MIN W/ SLOW DISKS?
command: make install
args:
2019-01-17 08:27:14 +00:00
chdir: "{{ asterisk_src_dir }}"
creates: /usr/sbin/asterisk
2019-02-09 19:42:27 +00:00
- name: Asterisk - Run 'make config'
2019-01-20 06:22:12 +00:00
command: make config
args:
chdir: "{{ asterisk_src_dir }}"
- name: Asterisk - Run 'make samples' - this creates /etc/asterisk/asterisk.conf used below
command: make samples
args:
chdir: "{{ asterisk_src_dir }}"
2019-01-19 13:37:24 +00:00
2019-02-09 19:42:27 +00:00
- name: Asterisk - Run 'ldconfig'
command: ldconfig
args:
2019-01-17 08:27:14 +00:00
chdir: "{{ asterisk_src_dir }}"
2021-08-06 23:54:26 +00:00
# 2021-08-06: Most install recipes do 'update-rc.d -f asterisk remove' here.
# Can't hurt but we do that a bit later in freepbx.yml
2021-08-06 23:54:26 +00:00
# 2021-08-06: Taken care of just below
# - name: Asterisk - Ensure group 'asterisk' exists
# group:
# name: asterisk
# state: present
#- name: Asterisk - Ensure system user 'asterisk' has primary group 'asterisk', groups 'audio,dialout', home '/var/lib/asterisk'
- name: Asterisk - Create Linux user 'asterisk'
user:
name: asterisk
2021-08-06 23:54:26 +00:00
# group: asterisk # 2021-08-06: Implicit
groups: audio,dialout # 2021-08-08: Plausibly might help?
home: /var/lib/asterisk # 2021-08-07: /home/asterisk (default) ok too
system: yes # 2021-08-08: No evidence this is needed. Hopefully it doesn't cause harm? (FYI Ansible doesn't change pre-existing users)
append: yes # 2021-08-08: Not essential. So Ansible adds groups w/o deleting existing group memberships.
2021-08-06 23:54:26 +00:00
# 2021-08-17: Moved to enable-or-disable.yml
# - name: Asterisk - Add user 'www-data' to group 'asterisk' - if pbx_use_nginx
# user:
# name: www-data
# groups: asterisk
# # system: yes # 2021-08-06: Ansible doesn't change pre-existing users
# append: yes
# when: pbx_use_nginx
2021-08-06 23:54:26 +00:00
- name: Asterisk - Set ownership for 6 directories (asterisk:asterisk, recurse)
file:
dest: "{{ item }}"
owner: asterisk
group: asterisk
recurse: yes
with_items:
2021-08-06 23:54:26 +00:00
- /var/run/asterisk
- /etc/asterisk
- /var/lib/asterisk
- /var/log/asterisk
- /var/spool/asterisk
- /usr/lib/asterisk
2019-02-09 19:54:22 +00:00
- name: Asterisk - Set default user to 'asterisk' in /etc/default/asterisk
lineinfile:
path: /etc/default/asterisk
regexp: 'AST_USER='
line: 'AST_USER="asterisk"'
2019-02-09 19:54:22 +00:00
- name: Asterisk - Set default group to 'asterisk' in /etc/default/asterisk
lineinfile:
path: /etc/default/asterisk
regexp: 'AST_GROUP='
line: 'AST_GROUP="asterisk"'
2019-02-09 19:54:22 +00:00
- name: Asterisk - Set default user to 'asterisk' in /etc/asterisk/asterisk.conf
lineinfile:
path: /etc/asterisk/asterisk.conf
regexp: 'runuser ='
line: 'runuser = asterisk'
2019-02-09 19:54:22 +00:00
- name: Asterisk - Set default group to 'asterisk' in /etc/asterisk/asterisk.conf
lineinfile:
path: /etc/asterisk/asterisk.conf
regexp: 'rungroup ='
line: 'rungroup = asterisk'