From 1074bba56f1a7c93cc42cbf16aa3d7bab7522e1a Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Thu, 7 Sep 2017 10:25:56 +0100 Subject: [PATCH] SUSE: Add ability to configure external mirror for openSUSE Allow deployers to choose a specific mirror by setting the 'lxc_hosts_opensuse_mirror_url' variable Change-Id: If151501923c5308cfeaee6e33d12df3e7f6959d5 --- defaults/main.yml | 8 ++++++++ .../opensuse-mirror-url-variable-6660f16c3e9bf1ff.yaml | 10 ++++++++++ vars/suse-42.yml | 9 ++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/opensuse-mirror-url-variable-6660f16c3e9bf1ff.yaml diff --git a/defaults/main.yml b/defaults/main.yml index f9710fd6..49029f3b 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -177,3 +177,11 @@ lxc_cache_download_template_options: >- # provided in EPEL is much too old (1.x). lxc_centos_package_baseurl: https://copr-be.cloud.fedoraproject.org/results/thm/lxc2.0/epel-7-x86_64/ lxc_centos_package_key: https://copr-be.cloud.fedoraproject.org/results/thm/lxc2.0/pubkey.gpg + +## Set default mirror for openSUSE repositories +# NOTE(hwoarang): Ensure that the full path to the 'opensuse' directory is used. +# Additionally, set 'lxc_hosts_opensuse_mirror_obs_url' to a mirror which also mirrors +# the OBS repositories. If you want to use the same mirror in both cases, then leave the +# 'lxc_hosts_opensuse_mirror_obs_url' to its default value. +lxc_hosts_opensuse_mirror_url: 'http://download.opensuse.org' +lxc_hosts_opensuse_mirror_obs_url: "{{ lxc_hosts_opensuse_mirror_url }}" diff --git a/releasenotes/notes/opensuse-mirror-url-variable-6660f16c3e9bf1ff.yaml b/releasenotes/notes/opensuse-mirror-url-variable-6660f16c3e9bf1ff.yaml new file mode 100644 index 00000000..858cc3a0 --- /dev/null +++ b/releasenotes/notes/opensuse-mirror-url-variable-6660f16c3e9bf1ff.yaml @@ -0,0 +1,10 @@ +--- +features: + - | + Deployers can set ``lxc_hosts_opensuse_mirror_url`` to use their + preferred mirror for the openSUSE repositories. They can also set the + ``lxc_hosts_opensuse_mirror_obs_url`` if they want to set a different + mirror for the OBS repositories. If they want to use the same mirror in + both cases then they can leave the latter variable to its default value. + The full list of mirrors and their capabilities can be obtained at + http://mirrors.opensuse.org/ diff --git a/vars/suse-42.yml b/vars/suse-42.yml index 9de9d7a0..ba58346e 100644 --- a/vars/suse-42.yml +++ b/vars/suse-42.yml @@ -16,7 +16,7 @@ lxc_hosts_external_repo: - name: "OBS:Virtualization:containers" - uri: "http://download.opensuse.org/repositories/Virtualization:/containers/openSUSE_Leap_{{ ansible_distribution_version }}/" + uri: "{{ lxc_hosts_opensuse_mirror_obs_url }}/repositories/Virtualization:/containers/openSUSE_Leap_{{ ansible_distribution_version }}/" system_config_dir: "/etc/sysconfig" systemd_utils_prefix: "/usr/lib/systemd" @@ -45,6 +45,8 @@ lxc_cache_map: copy_from_host: - /etc/environment - /etc/localtime + - /etc/zypp/repos.d/repo-oss + - /etc/zypp/repos.d/repo-update cache_prep_commands: | {{ lxc_cache_prep_pre_commands }} mkdir -p /etc/ansible/facts.d/ @@ -54,6 +56,11 @@ lxc_cache_map: {% for resolver in lxc_cache_prep_dns %} echo "nameserver {{ resolver }}" >> /etc/resolv.conf {% endfor %} + # Wipe default repositories and recreate them + find /etc/zypp/repos.d/*.repo -type f ! -name "repo-oss.repo"-o ! -name "repo-update.repo" -delete + # In case the host didn't have any of these two repos then create it (althought that indicates that the host is not in a good state!) + [[ ! -e /etc/zypp/repos.d/repo-oss.repo ]] && zypper --quiet ar {{ lxc_hosts_opensuse_mirror_url }}/distribution/leap/{{ ansible_distribution_version }}/repo/oss repo-oss + [[ ! -e /etc/zypp/repos.d/repo-update.repo ]] && zypper --quiet ar {{ lxc_hosts_opensuse_mirror_url }}/update/leap/{{ ansible_distribution_version }}/oss/ repo-update # Do a complete refresh and fetch the keys without asking zypper --gpg-auto-import-keys -n ref -f # Disable recommended packages. Only update what's really needed