---
- name: Set up mirror
  apt_repository:
    repo: "{{ item }}"
    update_cache: true
  with_items: "{{ apt_repositories }}"

- name: Wipe existing sources.list
  copy:
    content: '# Sources are located in /etc/apt/sources.list.d'
    dest: /etc/apt/sources.list
    force: true

- name: Perform a full upgrade
  apt:
    upgrade: dist
    update_cache: yes
    dpkg_options: 'force-confold,force-confdef'
  when: "ansible_ssh_user != 'vagrant'"

---
# This dummy resource ensures the python apt support is installed
# before we wipe the sources list in the next step
- name: Ensure python apt support is installed
  apt_repository:
    repo: deb http://dummy repo test
    state: absent

- name: Wipe existing sources.list
  copy:
    content: '# Sources are located in /etc/apt/sources.list.d'
    dest: /etc/apt/sources.list
    force: true

- name: Set up mirror
  apt_repository:
    repo: "{{ item }}"
    update_cache: true
  with_items: "{{ apt_repositories }}"

- name: Perform a full upgrade
  apt:
    upgrade: dist
    update_cache: yes
    dpkg_options: 'force-confold,force-confdef'
  when: ansible_ssh_user != 'vagrant'

Rework apt repos setup for Debian/Ubuntu
Rework apt repos setup for Debian/Ubuntu

This allows up to let ansible handle installing the python2/3-apt
package so we can simplify dependency installation

Change-Id: Ib2fac854e941de6a4f117ff940a549d1978a503c
