- name: software | google-chrome | add repository key | ubuntu
  apt_key:
    url: https://dl-ssl.google.com/linux/linux_signing_key.pub
  when: 
    - ansible_distribution in ["Debian", "Pop!_OS", "Ubuntu"]
    - chrome is defined
    - chrome == true

- name: software | google-chrome | add repository | ubuntu
  apt_repository:
    repo: "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main"
    filename: google-chrome
  register: chrome_repo
  when: 
    - ansible_distribution in ["Debian", "Pop!_OS", "Ubuntu"]
    - chrome is defined
    - chrome == true
    
- name: software | google-chrome | update sources (repo added or changed)
  apt:
    update_cache: yes
  changed_when: False
  when: chrome_repo.changed

- name: software | google-chrome | install package | ubuntu
  apt:
    name: google-chrome-stable
  when: 
    - ansible_distribution in ["Debian", "Pop!_OS", "Ubuntu"]
    - chrome is defined
    - chrome == true

- name: software | google-chrome | add repo | fedora
  shell: sudo dnf config-manager --set-enabled google-chrome
  when:
    - ansible_distribution in ["Fedora"]
    - chrome is defined
    - chrome == true

- name: software | google-chrome | install | fedora
  tags: packages,system,system-packages,workstation-packages
  package:
    name:
      - google-chrome-stable
  when: 
    - ansible_distribution in ["Fedora"]
    - chrome is defined
    - chrome == true
