---
- name: Download and convert Signal public software signing key
  shell: |
    wget -O- https://updates.signal.org/desktop/apt/keys.asc | gpg --dearmor -o /tmp/signal-desktop-keyring.gpg
  args:
    creates: /tmp/signal-desktop-keyring.gpg

- name: Move gpg key to apt keyring directory
  copy:
    src: /tmp/signal-desktop-keyring.gpg
    dest: /usr/share/keyrings/signal-desktop-keyring.gpg
    remote_src: yes

- name: Add Signal repository
  copy:
    content: "deb [arch=amd64 signed-by=/usr/share/keyrings/signal-desktop-keyring.gpg] https://updates.signal.org/desktop/apt xenial main\n"
    dest: /etc/apt/sources.list.d/signal-xenial.list

- name: Update apt cache
  apt:
    update_cache: yes

- name: Install Signal Desktop
  apt:
    name: signal-desktop
    state: present
