- name: software | sublime_text | add repository key
  apt_key:
    url: https://download.sublimetext.com/sublimehq-pub.gpg
  when: ansible_distribution in ["Debian", "Pop!_OS", "Ubuntu"]

- name: software | sublime_text | add repository
  apt_repository:
    repo: "deb https://download.sublimetext.com/ apt/stable/"
    filename: sublime_text
  register: sublime_text
  when: ansible_distribution in ["Debian", "Pop!_OS", "Ubuntu"]

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

- name: software | sublime_text | install package
  apt:
    name: 
      - sublime-text
      - sublime-merge
  when: ansible_distribution in ["Debian", "Pop!_OS", "Ubuntu"]


- name: software | sublime_text | add repository
  shell: sudo dnf config-manager --add-repo https://download.sublimetext.com/rpm/stable/x86_64/sublime-text.repo
  args:
    creates: /etc/yum.repos.d/sublime_text.repo 
  when: ansible_distribution in ["Fedora"]

- name: software | sublime_text | add repo key
  shell: sudo rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg
  when: ansible_distribution in ["Fedora"]

- name: software | sublime_text | install 
  tags: packages,system,system-packages,workstation-packages
  package:
    name:
      - sublime-text
      - sublime-merge
  when: ansible_distribution in ["Fedora"]

- name: software | sublime_text | add repository
  shell: sudo zypper addrepo -g -f https://download.sublimetext.com/rpm/stable/x86_64/sublime-text.repo
  args:
    creates: /etc/zypp/repos.d/sublime-text.repo 
  when: ansible_distribution in ["openSUSE Leap", "openSUSE Tumbleweed-Slowroll"]

- name: software | sublime_text | add repo key
  shell: sudo rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg
  when: ansible_distribution in ["openSUSE Leap", "openSUSE Tumbleweed-Slowroll"]

- name: software | sublime_text | install 
  tags: packages,system,system-packages,workstation-packages
  package:
    name:
      - sublime-text
      - sublime-merge
  when: ansible_distribution in ["openSUSE Leap", "openSUSE Tumbleweed-Slowroll"]