diff --git a/roles/configure-mirrors/defaults/main.yaml b/roles/configure-mirrors/defaults/main.yaml index 710a2ce23..5b7aa2e34 100644 --- a/roles/configure-mirrors/defaults/main.yaml +++ b/roles/configure-mirrors/defaults/main.yaml @@ -1 +1,2 @@ pypi_mirror: "http://{{ mirror_fqdn }}/pypi/simple" +wheel_mirror: "http://{{ mirror_fqdn }}/wheel/{{ ansible_distribution | lower }}-{{ ansible_distribution_version }}-{{ ansible_architecture | lower }}" diff --git a/roles/configure-mirrors/files/etc/apt/apt.conf.d/99unauthenticated b/roles/configure-mirrors/files/etc/apt/apt.conf.d/99unauthenticated deleted file mode 100644 index 351f64bcb..000000000 --- a/roles/configure-mirrors/files/etc/apt/apt.conf.d/99unauthenticated +++ /dev/null @@ -1,4 +0,0 @@ -# This file is generated by Ansible -# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN -# -APT::Get::AllowUnauthenticated "true"; diff --git a/roles/configure-mirrors/handlers/main.yaml b/roles/configure-mirrors/handlers/main.yaml new file mode 100644 index 000000000..b41e15af5 --- /dev/null +++ b/roles/configure-mirrors/handlers/main.yaml @@ -0,0 +1,5 @@ +# The apt module can not be used for this since it installs python-apt +# which can not work until this command fixes the cache. +- name: Update apt cache + become: yes + command: apt-get update diff --git a/roles/configure-mirrors/tasks/main.yaml b/roles/configure-mirrors/tasks/main.yaml index bba1f37b3..4f65d42b6 100644 --- a/roles/configure-mirrors/tasks/main.yaml +++ b/roles/configure-mirrors/tasks/main.yaml @@ -1,2 +1,4 @@ -- include: mirror.yaml +- name: Set up infrastructure mirrors + include: mirror.yaml when: mirror_fqdn is defined + static: no diff --git a/roles/configure-mirrors/tasks/mirror.yaml b/roles/configure-mirrors/tasks/mirror.yaml index d96d7ffc7..34e2581c8 100644 --- a/roles/configure-mirrors/tasks/mirror.yaml +++ b/roles/configure-mirrors/tasks/mirror.yaml @@ -1,6 +1,3 @@ -- name: Include OS-specific variables - include_vars: "{{ ansible_distribution | lower }}.yaml" - - name: Install /etc/pip.conf configuration become: yes template: @@ -16,11 +13,17 @@ mode: 0644 src: .pydistutils.cfg.j2 -- name: Setup distro specific packaging mirrors. - include: "packages/{{ ansible_distribution | lower }}.yaml" +- name: Include OS-specific variables + include_vars: "{{ item }}" + with_first_found: + - "{{ ansible_distribution }}.yaml" + - "{{ ansible_os_family }}.yaml" + - "default.yaml" -# Make sure OS does not have a stale package cache. -- name: Update apt cache - become: yes - command: apt-get update - when: ansible_os_family == 'Debian' +- name: Setup distribution specific packaging mirrors + include: "{{ item }}" + static: no + with_first_found: + - "mirror/{{ ansible_distribution }}.yaml" + - "mirror/{{ ansible_os_family }}.yaml" + - "mirror/default.yaml" diff --git a/roles/configure-mirrors/tasks/mirror/Ubuntu.yaml b/roles/configure-mirrors/tasks/mirror/Ubuntu.yaml new file mode 100644 index 000000000..eb68a8cd2 --- /dev/null +++ b/roles/configure-mirrors/tasks/mirror/Ubuntu.yaml @@ -0,0 +1,13 @@ +- name: Install Ubuntu repository files + become: yes + template: + dest: "/{{ item }}" + group: root + mode: 0644 + owner: root + src: "{{ item }}.j2" + with_items: + - etc/apt/sources.list + - etc/apt/apt.conf.d/99unauthenticated + notify: + - Update apt cache diff --git a/roles/configure-mirrors/tasks/mirror/default.yaml b/roles/configure-mirrors/tasks/mirror/default.yaml new file mode 100644 index 000000000..064c7b20a --- /dev/null +++ b/roles/configure-mirrors/tasks/mirror/default.yaml @@ -0,0 +1,6 @@ +- name: Warn about unsupported distribution + debug: + msg: > + WARNING: {{ ansible_distribution }} mirrors are not supported either + by this role yet. The execution of the job will continue without setting + up cached mirrors. diff --git a/roles/configure-mirrors/tasks/packages/ubuntu.yaml b/roles/configure-mirrors/tasks/packages/ubuntu.yaml deleted file mode 100644 index 5619df5eb..000000000 --- a/roles/configure-mirrors/tasks/packages/ubuntu.yaml +++ /dev/null @@ -1,17 +0,0 @@ -- name: Install /etc/apt/sources.list - become: yes - template: - dest: /etc/apt/sources.list - group: root - mode: 0644 - owner: root - src: etc/apt/sources.list.j2 - -- name: Install /etc/apt/apt.conf.d/99unauthenticated - become: yes - copy: - dest: /etc/apt/apt.conf.d/99unauthenticated - group: root - mode: 0644 - owner: root - src: etc/apt/apt.conf.d/99unauthenticated diff --git a/roles/configure-mirrors/templates/etc/apt/apt.conf.d/99unauthenticated.j2 b/roles/configure-mirrors/templates/etc/apt/apt.conf.d/99unauthenticated.j2 new file mode 100644 index 000000000..6bf00a089 --- /dev/null +++ b/roles/configure-mirrors/templates/etc/apt/apt.conf.d/99unauthenticated.j2 @@ -0,0 +1,2 @@ +# {{ ansible_managed }} +APT::Get::AllowUnauthenticated "true"; diff --git a/roles/configure-mirrors/vars/Ubuntu.yaml b/roles/configure-mirrors/vars/Ubuntu.yaml new file mode 100644 index 000000000..dece722ee --- /dev/null +++ b/roles/configure-mirrors/vars/Ubuntu.yaml @@ -0,0 +1 @@ +package_mirror: "http://{{ mirror_fqdn }}/{{ ansible_distribution | lower }}" diff --git a/roles/configure-mirrors/vars/default.yaml b/roles/configure-mirrors/vars/default.yaml new file mode 100644 index 000000000..4d29add77 --- /dev/null +++ b/roles/configure-mirrors/vars/default.yaml @@ -0,0 +1 @@ +package_mirror: diff --git a/roles/configure-mirrors/vars/ubuntu.yaml b/roles/configure-mirrors/vars/ubuntu.yaml deleted file mode 100644 index 3c59450ed..000000000 --- a/roles/configure-mirrors/vars/ubuntu.yaml +++ /dev/null @@ -1,2 +0,0 @@ -wheel_mirror: "http://{{ mirror_fqdn }}/wheel/{{ ansible_distribution | lower }}-{{ ansible_distribution_version }}-{{ ansible_architecture | lower }}" -package_mirror: "http://{{ mirror_fqdn }}/ubuntu"