---

- name: make sure out repo server is resolvable
  lineinfile: dest=/etc/hosts line="118.138.244.7 consistency0"
  sudo: true


#- name: remove default repos
#  file:
#    path: /etc/yum.repos.d/{{ item }}
#    state: absent
#  become: true
#  become_user: root
#  with_items:
#  - CentOS-Base.repo
#  - CentOS-Debuginfo.repo
#  - CentOS-fasttrack.repo
#  - CentOS-Sources.repo
#  - CentOS-Vault.repo
#  - foreman.repo
#  - puppetlabs.repo
#  - rdo-release.repo
#  - CentOS-CR.repo  
#  - CentOS-Media.repo  
#  - CentOS-OpenStack-kilo.repo 
#  - epel.repo
#  - monashhpc_mellanox.repo
#  - epel-testing.repo
#  when: ansible_os_family == 'RedHat' and ansible_distribution_major_version == "7"

- name: add our repos
  copy: src={{ item }} dest=/etc/yum.repos.d/{{ item }}
  sudo: true
  when: ansible_os_family == 'RedHat' and ansible_distribution_major_version == "7"
  with_items:
  - monashhpc_base.repo
  - monashhpc_others.repo

- name: get enabled repos
#shell: yum repolist | grep -v "repo id" | grep -v "Loaded plugins" | head -n -1 | cut -f 1 -d '/' | sed -s 's/\!//'
  shell: yum repolist all | grep enabled | cut -f 1 -d '/' | sed -s 's/\!//'
  register: repolist
  check_mode: no
  args: 
    warn: False

- name: disable unwanted repos
  shell: yum-config-manager --disable "{{ item }}"
  with_items: "{{repolist.stdout_lines|difference(yumenablerepo)}}"
  become: true
  become_user: root
  ignore_errors: true


#- name: Enable epel
#  command: yum-config-manager --enable epel
#  sudo: true
#  when: ansible_distribution == "CentOS" and ansible_distribution_major_version == "7"

# Use mate DE on systems that have moved to gnome3, since there is no gpu acceleration by default on NeCTAR openstack
# Trusty (Ubuntu 14.04 LTS) needs repos added. Wheezy (Debian Stable) gets mate from backports, Utopic (Ubuntu 14.10) Jessie (Debian testing) and Sid (Debian unstable) get it by default
- name: add repos apt
  shell: "add-apt-repository -y ppa:ubuntu-mate-dev/ppa"
  sudo: true
  when: ansible_distribution_release == 'trusty'

- name: add repos apt
  shell: "add-apt-repository -y ppa:ubuntu-mate-dev/trusty-mate"
  sudo: true
  when: ansible_distribution_release == 'trusty'

- name: add repos apt
  shell: "add-apt-repository -y ppa:gluster/glusterfs-3.7"
  sudo: true
  when: ansible_distribution == 'Ubuntu'

- name: apt-get update
  apt: update_cache=True
  sudo: true
  when: ansible_os_family=="Debian"
