Streamline configure-mirrors and Ubuntu repository setup

- Improve the structure to support multiple distributions
- Use one task to set up the different repository files
- Use handler to update the apt cache

Change-Id: I90933164cbca9d230cebeb3e2e1263c7806db840
This commit is contained in:
David Moreau-Simard 2017-09-06 22:25:00 -04:00
parent d55de6e54b
commit d45cfa287d
12 changed files with 45 additions and 34 deletions

View File

@ -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 }}"

View File

@ -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";

View File

@ -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

View File

@ -1,2 +1,4 @@
- include: mirror.yaml
- name: Set up infrastructure mirrors
include: mirror.yaml
when: mirror_fqdn is defined
static: no

View File

@ -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"

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -0,0 +1,2 @@
# {{ ansible_managed }}
APT::Get::AllowUnauthenticated "true";

View File

@ -0,0 +1 @@
package_mirror: "http://{{ mirror_fqdn }}/{{ ansible_distribution | lower }}"

View File

@ -0,0 +1 @@
package_mirror:

View File

@ -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"