---
- name: Check if EPEL repo is already configured
  stat:
    path: "{{ epel_repofile_path }}"
  register: epel_repofile_result

- name: Install EPEL repo
  yum:
    name: "{{ epel_repo_url }}"
    state: present
  register: result
  until: '"failed" not in result'
  retries: 5
  delay: 10
  when: not epel_repofile_result.stat.exists

- name: Import EPEL GPG key
  shell: rpm --import "{{ epel_repo_gpg_key_url }}"
  args:
    warn: no
  when: not epel_repofile_result.stat.exists
  ignore_errors: "{{ ansible_check_mode }}"

- name: Find all repo files
  raw: find /etc/yum.repos.d -type f -name "*.repo"
  register: repo_files

- name: Comment out mirror list for yum repos
  replace:
    dest: "{{ item }}"
    regexp: '^(mirrorlist.*)$'
    replace: '#\1'
  with_items: "{{ repo_files.stdout_lines }}"

- name: Set baseurl for repos
  replace:
    dest: "{{ item }}"
    regexp: '^.*baseurl=.*/(\w+)/(\$releasever|\d.*)/(.*)$'
    replace: 'baseurl=http://mirror.aarnet.edu.au/pub/\1/{{ ansible_distribution_major_version }}/\3'
  with_items: "{{ repo_files.stdout_lines }}"

- name: Perform a full upgrade
  yum:
    name: '*'
    state: latest
  when: nectar_test_build is not defined

---
- name: Check if EPEL repo is already configured
  stat:
    path: "{{ epel_repofile_path }}"
  register: epel_repofile_result

- name: Install EPEL repo
  yum:
    name: "{{ epel_repo_url }}"
    state: present
  register: result
  until: '"failed" not in result'
  retries: 5
  delay: 10
  when: not epel_repofile_result.stat.exists

- name: Import EPEL GPG key
  shell: rpm --import "{{ epel_repo_gpg_key_url }}"
  args:
    warn: no
  when: not epel_repofile_result.stat.exists
  ignore_errors: "{{ ansible_check_mode }}"

- name: Find all repo files
  raw: find /etc/yum.repos.d -type f -name "*.repo"
  register: repo_files

- name: Perform a full upgrade
  yum:
    name: '*'
    state: latest
  when: nectar_test_build is not defined

Revert to default mirrors for CentOS
Revert to default mirrors for CentOS

The method we used for setting the mirror doesn't work right
any more. Let yum work out the fastest, which will likely by
aarnet anyway

Change-Id: If5048ccefdf8cd529e56126589c2d9916b0fe8b4
