---
- name: Download the public GPG key
  ansible.builtin.get_url:
    url: "https://gitlab.com/{{ gitlab_login }}.gpg"
    dest: /tmp/public.gpg
    mode: 0600

- name: Import the public GPG key
  ansible.builtin.command:
    cmd: gpg --import /tmp/public.gpg
  register: gpg_import_result
  failed_when: gpg_import_result.rc != 0
  changed_when: "'imported: 1' in gpg_import_result.stdout"