---
- block:

  - name: Remove old docker repo
    apt_repository:
      repo: "deb https://apt.dockerproject.org/repo ubuntu-trusty main"
      state: absent

  - name: Ensure cached docker repo files are removed
    file:
      name: "{{ item }}"
      state: absent
    with_items:
      - /var/lib/apt/lists/apt.dockerproject.org_repo_dists_ubuntu-trusty_InRelease
      - /var/lib/apt/lists/apt.dockerproject.org_repo_dists_ubuntu-trusty_main_binary-amd64_Packages
      - /var/lib/apt/lists/apt.dockerproject.org_repo_dists_ubuntu-trusty_main_binary-i386_Packages

  - name: Add the llvm key
    apt_key:
      data: "{{ lookup('file', 'llvm-snapshot.gpg.key') }}"
      state: present

  - name: Add the mirrored llvm repository
    apt_repository:
      # TODO: Mirror this on artifactory
      repo: "deb [arch=amd64] https://apt.llvm.org/{{ os_release_name }}/ llvm-toolchain-{{ os_release_name }}-4.0 main"
      state: present
      filename: "llvm"

  - name: Add the git PPA
    apt_repository:
      repo: ppa:git-core/ppa

  # We want to use hkps servers when fetching public keys, but it will fail
  # unless this package is installed.
  - name: Install gnupg-curl to support hkps keyservers
    apt:
      name: gnupg-curl

  - name: Add debug symbols proposed apt repository
    apt_repository:
      repo: "deb [arch=amd64] {{ apt_mirror_base_url }}/ddebs.ubuntu.com/ {{ os_release_name }}-proposed main restricted universe multiverse"
      state: present
      filename: "ddebs_proposed"

  - name: Add the signature key for python gdal
    apt_key:
      keyserver: "{{ keyserver }}"
      id: "{{ python_gdal_key_server_id }}"

  - name: Add the mirrored python gdal
    apt_repository:
      repo: "deb [arch=amd64] {{ apt_mirror_base_url }}/ppa.launchpad.net/ubuntugis/ppa/ubuntu/ trusty main"
      state: present
      filename: "gdal"

  - name: Add the signature key for trusty_media
    apt_key:
      keyserver: "{{ keyserver }}"
      id: "{{ trusty_media_key_server_id }}"

  - name: Add the mirror for video
    apt_repository:
      repo: "deb [arch=amd64] {{ apt_mirror_base_url }}/ppa.launchpad.net/mc3man/trusty-media/ubuntu/ trusty main"
      state: present
      filename: "video"

  become: yes
