Skip to content

Instantly share code, notes, and snippets.

@defnull
Created April 4, 2023 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save defnull/998f9217cb56edcc397ec6a1d46bb1c0 to your computer and use it in GitHub Desktop.
Save defnull/998f9217cb56edcc397ec6a1d46bb1c0 to your computer and use it in GitHub Desktop.
Ansible cluster setup for BBB

How To deploy an anible-role-bigbluebutton cluster with the Proxy Setup

Configuration per BBB node

bbb_lbmode:
  # Loadbalancer domain name (e.g. example.com)
  host: "{{ bbblb_domain }}"
  # Node name (e.g. bbb01, defaults to subdomain)
  name: "{{ bbb_nodename | default(inventory_hostname.split('.')[0]) }}"

Task to run BEFORE anible-role-bigbluebutton to update bbb_meteor fact.

- name: Enable lbmode
  when: "bbb_lbmode|default(False)"
  set_fact:
    bbb_meteor: |
      {{bbb_meteor|default({})|combine({
        'public': {
          'app': {
            'basename': "/"+bbb_lbmode.name+"/html5client",
            'bbbWebBase': 'https://'+bbb_hostname+'/bigbluebutton',
            'learningDashboardBase': 'https://'+bbb_hostname+'/learning-dashboard',
            'userSettingsStorage': 'local',
          },
          'media': {
            'stunTurnServersFetchAddress': 'https://'+bbb_hostname+'/bigbluebutton/api/stuns',
            'sip_ws_host': bbb_hostname,
          },
          'presentation': {
            'uploadEndpoint': 'https://'+bbb_hostname+'/bigbluebutton/presentation/upload'
          },
          'pads': {
            'url': 'https://'+bbb_hostname+'/pad'
          }
        }
      }, recursive=True)}}

Tasks to run AFTER anible-role-bigbluebutton (or to be integrated into the role)

- name: lbmode for /etc/bigbluebutton/bbb-web.properties
  ansible.builtin.lineinfile:
    path: /etc/bigbluebutton/bbb-web.properties
    regexp: "^{{item.split('=')[0]}}="
    line: "{{item}}"
  loop:
    - defaultHTML5ClientUrl=https://{{bbb_lbmode.host}}/{{bbb_lbmode.name}}/html5client/join
    - defaultGuestWaitURL=https://{{bbb_lbmode.host}}/{{bbb_lbmode.name}}/html5client/guestWait
    - presentationBaseURL=https://{{bbb_hostname}}/bigbluebutton/presentation
    - accessControlAllowOrigin=https://{{bbb_lbmode.host}}
  notify:
  - restart bbb

- name: lbmode override meteor ROOT_URL
  ansible.builtin.copy:
    dest: "{{item}}"
    content: |
      [Service]
      Environment=ROOT_URL=https://{{bbb_lbmode.host}}/{{bbb_lbmode.name}}/html5client
      Environment=DDP_DEFAULT_CONNECTION_URL=https://{{bbb_hostname}}/{{bbb_lbmode.name}}/html5client
  loop:
    - /etc/systemd/system/bbb-html5-frontend@.service.d/cluster.conf
    - /etc/systemd/system/bbb-html5-backend@.service.d/cluster.conf
  notify:
    - reload systemd
    - restart bbb

- name: lbmode configure etherpad
  ansible.builtin.copy:
    dest: "/etc/bigbluebutton/etherpad.json"
    content: '{"cluster_proxies": ["https://{{bbb_lbmode.host}}"]}'
  notify:
    - restart bbb

- name: lbmode set nginx bbb_loadbalancer_node
  ansible.builtin.copy:
    dest: "/usr/share/bigbluebutton/nginx/loadbalancer.nginx"
    content: "set $bbb_loadbalancer_node https://{{bbb_lbmode.host}};"
  notify:
    - reload nginx

- name: lbmode fix /usr/share/bigbluebutton/nginx/bbb-html5.nginx
  ansible.builtin.replace:
    path: /usr/share/bigbluebutton/nginx/bbb-html5.nginx
    regexp: 'location (/[^/]+)?/html5client'
    replace: "location /{{bbb_lbmode.name}}/html5client"
  notify:
    - reload nginx

- name: lbmode fix /etc/default/bbb-web
  ansible.builtin.lineinfile:
    path: /etc/default/bbb-web
    regexp: '^JDK_JAVA_OPTIONS=.*'
    line: 'JDK_JAVA_OPTIONS="-Dgrails.cors.enabled=true -Dgrails.cors.allowCredentials=true -Dgrails.cors.allowedOrigins=https://{{bbb_hostname}},https://{{bbb_lbmode.host}}"'
  notify:
    - restart bbb

- name: lbmode custom guest-wait.html
  ansible.builtin.template:
    src: guest-wait.html.j2
    dest: /usr/share/meteor/bundle/programs/server/assets/app/static/guest-wait/guest-wait.html
  notify:
    - restart bbb

guest-wait.yaml also needs a fix:

...
  <script type="text/javascript">
    {% if bbb_lbmode|default(False) %}
    const CLIENT_BASE = "https://{{bbb_lbmode.host}}/{{bbb_lbmode.name}}/html5client"
    {% else %}
    const CLIENT_BASE = "https://{{bbb_hostname}}/html5client"
    {% endif %}
    const API_BASE = "https://{{bbb_hostname}}/bigbluebutton/api"
    

Add nginx routes on loadbalancer (e.g. scalelite), one for each backend node

{% for host in groups['bbb'] %}
{% if hostvars[host].get('bbb_lbmode') %}
location /{{hostvars[host].bbb_lbmode.name}}/html5client/ {
    proxy_pass https://{{host}};
}
{% endif %}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment