- name: software | brave | add repository key
  apt_key:
    url: https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg
  when: ansible_distribution in ["Debian", "Pop!_OS", "Ubuntu"]

- name: software | brave | add repository
  apt_repository:
    repo: "deb [arch=amd64] https://brave-browser-apt-release.s3.brave.com/ stable main"
    filename: brave-browser
  register: brave_browser
  when: ansible_distribution in ["Debian", "Pop!_OS", "Ubuntu"]

- name: software | brave | update sources (repo added or changed)
  apt:
    update_cache: yes
  changed_when: False
  when: brave_browser.changed

- name: software | brave | install package
  apt:
    name: brave-browser
  when: ansible_distribution in ["Debian", "Pop!_OS", "Ubuntu"]


- name: software | brave | add repository
  shell: sudo dnf config-manager --add-repo https://brave-browser-rpm-release.s3.brave.com/x86_64/
  args:
    creates: /etc/yum.repos.d/brave.repo 
  when: ansible_distribution in ["Fedora"]

- name: software | brave | add repo key
  shell: sudo rpm --import https://brave-browser-rpm-release.s3.brave.com/brave-core.asc
  args:
    creates: /etc/yum.repos.d/brave.repo 
  when: ansible_distribution in ["Fedora"]

- name: software | brave | install 
  tags: packages,system,system-packages,workstation-packages
  package:
    name:
      - brave-browser
  when: ansible_distribution in ["Fedora"]

- name: software | brave | add repository
  community.general.zypper_repository:
   # name: brave-browser
    repo: 'https://brave-browser-rpm-release.s3.brave.com/brave-browser.repo'
    state: present
  when: ansible_distribution in ["openSUSE Leap", "openSUSE Tumbleweed-Slowroll"]

- name: software | brave | install 
  tags: packages,system,system-packages,workstation-packages
  zypper:
    name:
      - brave-browser
  when: ansible_distribution in ["openSUSE Leap", "openSUSE Tumbleweed-Slowroll"]