- name: jitsimeet | adjust limits
  blockinfile:
    path: "/etc/systemd/system.conf"
    block: |
      DefaultLimitNOFILE=65000
      DefaultLimitNPROC=65000
      DefaultTasksMax=65000

- block:
  - name: jitsimeet | reload systemd
    systemd:
      daemon_reload: true
    when: preinstalled == false or preinstalled is not defined

  - name: jitsimeet | import GPG keys
    get_url:
      url: "{{ item }}" # required. HTTP, HTTPS, or FTP URL in the form (http|https|ftp)://[user[:pass]]@host.domain[:port]/path
      dest: "/etc/apt/keyrings/{{ item | urlsplit('path') | basename | splitext | first}}.asc"  # required. Absolute path of where to download the file to. If C(dest) is a directory, either the server provided filename or, if none provided, the base name of the URL on the remote server will be used. If a directory, C(force) has no effect. If C(dest) is a directory, the file will always be downloaded (regardless of the C(force) option), but replaced only if the contents changed..
    loop:
      - "https://prosody.im/files/prosody-debian-packages.key"
      - "https://download.jitsi.org/jitsi-key.gpg.key"
    
    apt_key:
      url: "https://download.jitsi.org/jitsi-key.gpg.key"
      state: present # not required. choices: absent;present. Ensures that the key is present (added) or absent (revoked).
    when: preinstalled == false or preinstalled is not defined

  - name: jitsimeet | add repository
    lineinfile:
      path: "/etc/apt/sources.list.d/jitsi-stable.list"
      line: "deb https://download.jitsi.org stable/"
      create: True
      backup: True
    notify: apt_update
    when: preinstalled == false or preinstalled is not defined

  - name: jitsimeet | flush handlers
    meta: flush_handlers

  - name: jitsimeet | add debconf-utils package
    package:
      name: debconf-utils
      state: latest
    when: preinstalled == false or preinstalled is not defined