---
- block:
  - name: Install the Mono dependencies on Deb based distributions
    apt: name={{ mono_deb_prerequisites }} state=present cache_valid_time=1800

  when: ansible_distribution_file_variety == "Debian"
  tags: mono

- block:
  - name: Install the deb Mono repository key
    apt_key:
      keyserver: {{ mono_repo_server }}
      url: {{ mono_repo_server }}
      id: {[ mono_deb_repo_key_id }}

  - name: Install the deb Mono repository
    apt_repository:
      repo: '{{ mono_deb_repo_url }}'
      state: present
      update_cache: yes

  - name: Install the Mono packages on Deb based distributions
    apt: name={{ mono_deb_packages }} state=present cache_valid_time=1800

  when: ansible_distribution_file_variety == "Debian"
  tags: mono

- block:
  - name: Install the RH Mono repository key
    rpm_key:
      state: present
      key: {{ mono_rh_key }}

  - name: Install the RH Mono repository
    get_url:
      dest: /etc/yum.repos.d/mono-{{ ansible_distribution | lower }}{{ ansible_distribution_major_version }}-stable.repo
      url: {{ mono_rh_repo_url }}

  - name: Install the Mono packages on RH based distributions
    yum: name={{ mono_rh_packages }} state=present

  when: ansible_distribution_file_variety != "Debian"
  tags: mono