From 1d84d33636fd8283645f9d56c91167294d3bbf60 Mon Sep 17 00:00:00 2001 From: Daniel Kobras Date: Mon, 27 Jul 2020 21:45:27 +0200 Subject: [PATCH] Allow configuration of SIP dial-in --- README.md | 24 ++++++++++++++++ tasks/firewall.yml | 12 ++++++++ tasks/main.yml | 4 +++ tasks/sip.yml | 53 +++++++++++++++++++++++++++++++++++ templates/sip_dialplan.xml.j2 | 15 ++++++++++ templates/sip_provider.xml.j2 | 7 +++++ 6 files changed, 115 insertions(+) create mode 100644 tasks/sip.yml create mode 100644 templates/sip_dialplan.xml.j2 create mode 100644 templates/sip_provider.xml.j2 diff --git a/README.md b/README.md index 171131a..dfd69f0 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,12 @@ To get up _BigBlueButton_ up and running the following variables can be configur * `bbb_install_webhooks`: Install the bbb-webhooks package, useful to integrate bbb into other web applications (Default: `True`). * `bbb_install_greenlight`: Install the Greenlight frontend (Default: `False`) +To configure optional SIP dial-in, define a dict `bbb_sip_providers` (Default: unset) to supply information about each SIP provider. Each key in the dict +corresponds to a provider config. Its value is another dict where each key maps to a parameter of the same name in the BBB SIP configuration. At least +`username`, `password` (for the SIP credentials), `proxy` (FQDN of the SIP gateway), and extension (dial-in number) have to be set. The default dial-in +number for display in human-readable format should be supplied in `bbb_sip_default_dialin`. A verbose dial-in message can be supplied in +`bbb_sip_welcome_footer` (defaults to the message example given in the BBB SIP documentation). + In order to deploy a basic setup of the _Greenlight_ frontend alongside _BigBlueButton_, the following variables can be set: * `bbb_greenlight_image`: Docker image to run for Greenlight (Default: `bigbluebutton/greenlight:v2`) @@ -68,5 +74,23 @@ In order to deploy a basic setup of the _Greenlight_ frontend alongside _BigBlue bbb_install_check: True bbb_configure_ssl: True bbb_ssl_email: foo@bar.com + bbb_sip_default_dialin: "+613-555-1234" + bbb_sip_welcome_footer: "

dial %%DIALNUM%%, then enter %%CONFNUM%% as conference PIN." + bbb_sip_providers: + sipprovider1: + username: "123456789" + password: "topsecret" + extension: "6135551234" + proxy: sip.example.com + register: "true" + context: "public" + sipprovider2: + username: "11114444" + password: "changeme" + extension: "8005554321" + proxy: sip.example.org + register: "true" + context: "public" + ``` diff --git a/tasks/firewall.yml b/tasks/firewall.yml index 8b84664..ad44730 100644 --- a/tasks/firewall.yml +++ b/tasks/firewall.yml @@ -28,6 +28,18 @@ tags: - bbb_configure_ufw +- name: Allow connections from SIP gateways in firewall + ufw: + rule: allow + from: "{{ lookup('dig', item[0]) }}" + port: "5060,5080" + proto: "{{ item[1] }}" + comment: "SIP gateway" + loop: "{{ bbb_sip_providers.values() | map(attribute='proxy') | product(['tcp', 'udp']) | list }}" + when: bbb_sip_providers is defined + tags: + - bbb_configure_ufw + - name: Enable firewall rules ufw: state: enabled diff --git a/tasks/main.yml b/tasks/main.yml index ac7cab7..a06cf29 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -224,6 +224,10 @@ when: bbb_configure_ssl == True - include_tasks: ssl.yml when: bbb_configure_ssl == True +- include_tasks: sip.yml + when: bbb_sip_providers is defined + tags: + - bbb-sip - name: Restart BigBlueButton command: bbb-conf --restart diff --git a/tasks/sip.yml b/tasks/sip.yml new file mode 100644 index 0000000..e47427a --- /dev/null +++ b/tasks/sip.yml @@ -0,0 +1,53 @@ +--- +- name: Create external SIP provider configuration for FreeSWITCH + template: + src: templates/sip_provider.xml.j2 + dest: /opt/freeswitch/conf/sip_profiles/external/{{ item.key }}.xml + owner: freeswitch + group: daemon + backup: yes + loop: "{{ bbb_sip_providers | dict2items }}" + register: sip_profile_config + no_log: true + tags: + - bbb-add-sip-provider-config + +- name: Create dialplan for SIP provider + template: + src: templates/sip_dialplan.xml.j2 + dest: /opt/freeswitch/conf/dialplan/{{ item.value.context | default("public") }}/{{ item.key }}.xml + owner: freeswitch + group: daemon + backup: yes + loop: "{{ bbb_sip_providers | dict2items }}" + register: sip_dialin_config + no_log: true + tags: + - bbb-add-sip-provider-config + +- name: Restart FreeSWITCH to activate SIP changes + systemd: + name: freeswitch + state: restarted + when: + sip_profile_config.changed or sip_dialin_config.changed + tags: + - bbb-add-sip-provider-config + +- name: Configure default dial-in number + replace: + path: "/usr/share/bbb-web/WEB-INF/classes/bigbluebutton.properties" + regexp: '^defaultDialAccessNumber=.*' + replace: 'defaultDialAccessNumber={{ bbb_sip_default_dialin | default("+" + (bbb_sip_providers.values() | first).extension) }}' + backup: yes + tags: + - bbb-add-sip-dialin-config + +- name: Configure dial-in numbers in welcome footer + replace: + path: "/usr/share/bbb-web/WEB-INF/classes/bigbluebutton.properties" + regexp: '^defaultWelcomeMessageFooter=.*' + replace: 'defaultWelcomeMessageFooter={{ bbb_sip_welcome_footer | default("

To join this meeting by phone, dial:
%%DIALNUM%%
Then enter %%CONFNUM%% as the conference PIN number.") }}' + backup: yes + tags: + - bbb-add-sip-dialin-config diff --git a/templates/sip_dialplan.xml.j2 b/templates/sip_dialplan.xml.j2 new file mode 100644 index 0000000..c7cae2d --- /dev/null +++ b/templates/sip_dialplan.xml.j2 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/templates/sip_provider.xml.j2 b/templates/sip_provider.xml.j2 new file mode 100644 index 0000000..2b95a53 --- /dev/null +++ b/templates/sip_provider.xml.j2 @@ -0,0 +1,7 @@ + + +{% for param in item.value | dict2items %} + +{% endfor %} + +