- name: download gpg
  ansible.builtin.get_url:
    url: "{{ item.url }}"
    dest: "/etc/apt/keyrings/{{ item.name }}.asc"
  with_items: "{{ apt_repo_gpg }}"
  become: yes
  when: apt_repo_gpg is defined

- name: add apt repository key
  apt_key:
    url: "{{ item }}"
  with_items: "{{ apt_keys }}"
  become: yes
  when: apt_keys is defined   

- name: add apt repository
  apt_repository:
    repo: "{{ item }}"
  with_items: "{{ apt_repo }}"
  become: yes
  when: apt_repo is defined   

- name: Upgrade Packages
  package:
    update_cache: yes
    upgrade: safe 
  become: yes
  when: required_packages_apt is defined   

- name: Install Packages
  apt:
    state: latest
    update_cache: yes
    pkg: "{{ required_packages_apt }}"
  become: yes
  when: required_packages_apt is defined   
