---
  - name: Update Freeswitch STUN address with server IP address
    ansible.builtin.replace:
      path: /opt/freeswitch/etc/freeswitch/vars.xml
      regexp: 'stun:stun.freeswitch.org'
      replace: '{{ server_ip }}'
      backup: true
    tags:
      - bbb_configure_nat
  - name: Configure Freeswitch SIP profiles
    ansible.builtin.replace:
      path: /opt/freeswitch/conf/sip_profiles/external.xml
      regexp: 'ext-rtp-ip\" value=\"\$\${local_ip_v4'
      replace: 'ext-rtp-ip\" value=\"\$\${external_rtp_ip'
      backup: true
    tags:
      - bbb_configure_nat
  - name: Configure Freeswitch SIP profiles
    ansible.builtin.replace:
      path: /opt/freeswitch/conf/sip_profiles/external.xml
      regexp: 'ext-sip-ip\" value=\"\$\${local_ip_v4'
      replace: 'ext-sip-ip\" value=\"\$\${external_sip_ip'
      backup: true
    tags:
      - bbb_configure_nat
  - name: Configure Freeswitch SIP profiles
    ansible.builtin.replace:
      path: /opt/freeswitch/conf/sip_profiles/external.xml
      regexp: '<param name=\"ws-binding\".*'
      replace: '<param name=\"ws-binding\"  value=\"{{ server_ip }}:5066\"'
      backup: true
    tags:
      - bbb_configure_nat
  - name: Update nginx SIP configuration
    ansible.builtin.replace:
      path: /etc/bigbluebutton/nginx/sip.nginx
      regexp: '{{ internal_ip }}:'
      replace: '{{ server_ip }}:'
      backup: true
    tags:
      - bbb_configure_nat
  - name: Create dummy nic for FreeSWITCH
    ansible.builtin.template:
      src: templates/dmmy_nic.j2
      dest: /lib/systemd/system/dummy-nic.service
      backup: true
    tags:
      - bbb-create_dummy_nic
  - name: Reload dummy nic
    ansible.builtin.systemd:
      state: restarted
      daemon_reload: true
      enabled: true
      name: dummy-nic
    tags:
      - bbb-reload_dummy_nic
