---

- name: Assert
  assert:
    that:
    - "ansible_pkg_mgr == 'apt'"
    - "extra_repos is defined"

- name: Add additional apt repository keys
  with_items: extra_repos
  when: item.key_url is defined or item.key_data is defined
  apt_key:
    url: '{{ item.key_url|default(omit) }}'
    data: '{{ item.key_data|default(omit) }}'
    state: present

- name: Add additional apt repository
  with_items: extra_repos
  apt_repository:
    repo: '{{ item.repo }}'
    state: present
    update_cache: yes
