---
- name: Ensure curl is installed
  apt:
    name: curl
    state: present
    update_cache: yes

- name: Download Brave browser GPG key
  get_url:
    url: https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg
    dest: /usr/share/keyrings/brave-browser-archive-keyring.gpg
    mode: '0644'
    owner: root
    group: root

- name: Add Brave browser repository
  apt_repository:
    repo: "deb [signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg] https://brave-browser-apt-release.s3.brave.com/ stable main"
    state: present
    filename: "brave-browser-release.list"

- name: Update apt cache
  apt:
    update_cache: yes

- name: Install Brave browser
  apt:
    name: brave-browser
    state: present

