From ae6a0055d475fdfbabf59790d5810465b8d85d0a Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Tue, 7 Mar 2017 12:51:49 +0000 Subject: [PATCH] AIO: Provide facility to exclude apt distributions When using a mirror which compiles all apt sources into a single repo with the intent of relying on that repo for all package updates the /etc/apt/sources.list file must contain only the base ubuntu repo. This patch adds the ability to implement an AIO with this kind of apt sources configuration, while keeping the current configuration that's used for gating. Change-Id: Ia9785a43c9027df86f3bc94f825aba3c43a96e4c --- tests/roles/bootstrap-host/defaults/main.yml | 5 +++++ .../bootstrap-host/tasks/install_packages.yml | 11 ++++++++--- .../templates/apt-sources.list.j2 | 18 ++++++++++++------ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/tests/roles/bootstrap-host/defaults/main.yml b/tests/roles/bootstrap-host/defaults/main.yml index 66700b973c..24c012595b 100644 --- a/tests/roles/bootstrap-host/defaults/main.yml +++ b/tests/roles/bootstrap-host/defaults/main.yml @@ -196,6 +196,11 @@ bootstrap_host_data_disk_min_size: 50 #bootstrap_host_ubuntu_repo: http://archive.ubuntu.com/ubuntu/ #bootstrap_host_ubuntu_security_repo: http://archive.ubuntu.com/ubuntu/ +# Set the distribution suffixes that will be included in the apt repository configuration +bootstrap_host_apt_distribution_suffix_list: + - updates + - backports + # Set the components that will be included in the apt repository configuration bootstrap_host_apt_components: - main diff --git a/tests/roles/bootstrap-host/tasks/install_packages.yml b/tests/roles/bootstrap-host/tasks/install_packages.yml index 19c18054d3..2a52fb23ff 100644 --- a/tests/roles/bootstrap-host/tasks/install_packages.yml +++ b/tests/roles/bootstrap-host/tasks/install_packages.yml @@ -37,18 +37,24 @@ when: - bootstrap_host_ubuntu_security_repo is not defined changed_when: false + failed_when: false tags: - find-apt-security-repo - name: Set apt repo facts based on discovered information set_fact: bootstrap_host_ubuntu_repo: "{{ ubuntu_repo.stdout_lines[0] }}" - bootstrap_host_ubuntu_security_repo: "{{ ubuntu_security_repo.stdout_lines[0] }}" when: - bootstrap_host_ubuntu_repo is not defined - - bootstrap_host_ubuntu_security_repo is not defined - ubuntu_repo is defined + + - name: Set apt security repo facts based on discovered information + set_fact: + bootstrap_host_ubuntu_security_repo: "{{ ubuntu_security_repo.stdout_lines[0] }}" + when: + - bootstrap_host_ubuntu_security_repo is not defined - ubuntu_security_repo is defined + - ubuntu_security_repo.stdout_lines | length > 0 - name: Configure apt's sources.list (Ubuntu only) template: @@ -58,7 +64,6 @@ when: - ansible_distribution == 'Ubuntu' - bootstrap_host_ubuntu_repo is defined - - bootstrap_host_ubuntu_security_repo is defined register: apt_sources_configure - name: Update apt-cache diff --git a/tests/roles/bootstrap-host/templates/apt-sources.list.j2 b/tests/roles/bootstrap-host/templates/apt-sources.list.j2 index 8a632a1092..83afc4aa26 100644 --- a/tests/roles/bootstrap-host/templates/apt-sources.list.j2 +++ b/tests/roles/bootstrap-host/templates/apt-sources.list.j2 @@ -1,10 +1,16 @@ # {{ ansible_managed }} -# Base repositories +# Base repository deb {{ bootstrap_host_ubuntu_repo }} {{ ansible_distribution_release }} {{ bootstrap_host_apt_components | join(" ") }} -# Updates repositories -deb {{ bootstrap_host_ubuntu_repo }} {{ ansible_distribution_release }}-updates {{ bootstrap_host_apt_components | join(" ") }} -# Backports repositories -deb {{ bootstrap_host_ubuntu_repo }} {{ ansible_distribution_release }}-backports {{ bootstrap_host_apt_components | join(" ") }} -# Security repositories + +{% if bootstrap_host_apt_distribution_suffix_list | length > 0 %} +# Additional distribution repositories +{% for suffix in bootstrap_host_apt_distribution_suffix_list %} +deb {{ bootstrap_host_ubuntu_repo }} {{ ansible_distribution_release }}-{{ suffix }} {{ bootstrap_host_apt_components | join(" ") }} +{% endfor %} +{% endif %} + +{% if bootstrap_host_ubuntu_security_repo is defined %} +# Security repository deb {{ bootstrap_host_ubuntu_security_repo }} {{ ansible_distribution_release }}-security {{ bootstrap_host_apt_components | join(" ") }} +{% endif %}