- block:

  - name: Copy the new sources list
    template:
      src: "sources.list"
      dest: /etc/apt/sources.list
      mode: '644'

  - 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 docker repo key
    apt_key:
      id: "{{ docker_apt_key }}"
      keyserver: keyserver.ubuntu.com


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

  - name: Add the mirrored llvm repository
    apt_repository:
      repo: "deb [arch=amd64] {{ apt_mirror_base_url }}/apt.llvm.org/trusty/ llvm-toolchain-trusty-4.0 main"
      state: present
      filename: "llvm"

  - name: Add the git PPA
    apt_repository:
      repo: ppa:git-core/ppa
    when: ansible_distribution_version == '14.04'

  # 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
    when: ansible_distribution_version == '14.04'

  - name: Install debug symbols apt repository key
    apt_key:
      data: "{{ lookup('file', 'dbgsym-release-key.asc') }}"
      state: present

  - name: Add debug symbols apt repository for trusty
    apt_repository:
      repo: "deb [arch=amd64] {{ apt_mirror_base_url }}/ddebs.ubuntu.com/ trusty main restricted universe multiverse"
      state: present
      filename: "ddebs"
    when: ansible_distribution_version == '14.04'

  - name: Add debug symbols apt repository for trusty-updates
    apt_repository:
      repo: "deb [arch=amd64] {{ apt_mirror_base_url }}/ddebs.ubuntu.com/ trusty-updates main restricted universe multiverse"
      state: present
      filename: "ddebs_updates"
    when: ansible_distribution_version == '14.04'

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

  - name: Add deadsnakes PPA signature
    apt_key:
      keyserver: "{{ keyserver }}"
      id: "{{ deadsnakes_apt_key_id }}"

  - name: Add deadsnakes PPA
    apt_repository:
      repo: "deb [arch=amd64] {{ apt_mirror_base_url }}/ppa.launchpad.net/deadsnakes/ppa/ubuntu trusty main"
      state: present
      filename: "deadsnakes"
    when: ansible_distribution_version == '14.04'

  - name: Add the signature key for python gdal
    apt_key:
      keyserver: "{{ keyserver }}"
      id: "{{ python_gdal_key_server_id }}"
    when: ansible_distribution_version == '14.04'

  - 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"
    when: ansible_distribution_version == '14.04'

  - 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"
    when: ansible_distribution_version == '14.04'

  - name: Install testing toolchain apt repository key
    apt_key:
      data: "{{ lookup('file', 'ubuntu-toolchain-r-test.asc') }}"
      state: present

  - name: Add testing toolchain apt repository for trusty
    apt_repository:
      repo: "deb [arch=amd64] {{ apt_mirror_base_url }}/ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu trusty main"
      state: present
      filename: "ubuntu-toolchain-r-test-trusty"
    when: ansible_distribution_version == '14.04'

  - name: Add testing toolchain apt repository for trusty
    apt_repository:
      repo: "deb [arch=i386] http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu trusty main"
      state: present
      filename: "ubuntu-toolchain-r-test-trusty"
    when: ansible_distribution_version == '14.04'

  - name: Update apt cache
    apt:
      update_cache: yes
      cache_valid_time: "{{ apt_cache_valid_time }}"

  become: yes
