diff --git a/tasks/lxc_cache_prestage.yml b/tasks/lxc_cache_prestage.yml index 6e88f1a0..5d4fbff6 100644 --- a/tasks/lxc_cache_prestage.yml +++ b/tasks/lxc_cache_prestage.yml @@ -45,6 +45,14 @@ set_fact: cache_basename: "{{ lxc_hosts_container_image_url | basename }}" +- name: Create aria2c output script + template: + src: aria2c-download-helper.sh.j2 + dest: /usr/local/bin/aria2c-download-helper.sh + owner: "root" + group: "root" + mode: "0755" + - name: Pre-stage the LXC image on the system shell: > aria2c @@ -53,6 +61,8 @@ --dir=/tmp --out={{ cache_basename }} --check-certificate={{ (lxc_hosts_validate_certs | bool) | lower }} + --follow-metalink=mem + --on-download-complete=/usr/local/bin/aria2c-download-helper.sh {{ lxc_hosts_container_image_url }} > /var/log/aria2c-image-prestage.log 2>&1 args: diff --git a/tasks/lxc_install_zypper.yml b/tasks/lxc_install_zypper.yml index e8cb43ec..fd7a5047 100644 --- a/tasks/lxc_install_zypper.yml +++ b/tasks/lxc_install_zypper.yml @@ -63,12 +63,3 @@ enabled: "yes" tags: - lxc_hosts-config - -- name: Determine latest openSUSE container build information (Leap 15) - # NOTE(hwoarang) The build ID changes all the time so we need to have a hack to determine the latest one - # NOTE(evrardjp) You can still build using your own image by setting lxc_hosts_container_image_url in user_variables. - # NOTE(noonedeadpunk) While suse has static metalink which allows to get to the most recent build, - # aria2c do not save files provided by metalinks under expected names, as --out do not work for them. - shell: | - curl -s {{ _lxc_hosts_container_image_url_base }} | grep -P -o '{{ ansible_architecture }}.*?lxc.*?Build.*?xz' | head -n 1 - register: _lxc_opensuse_image_build_info diff --git a/templates/aria2c-download-helper.sh.j2 b/templates/aria2c-download-helper.sh.j2 new file mode 100644 index 00000000..94a42232 --- /dev/null +++ b/templates/aria2c-download-helper.sh.j2 @@ -0,0 +1,10 @@ +#!/bin/bash + +set -x -e + +real_name="$3" +link_name="/tmp/{{ cache_basename }}" + +if [[ ${real_name} != ${link_name} ]]; then + ln --symbolic "${real_name}" "${link_name}" +fi diff --git a/vars/suse.yml b/vars/suse.yml index 4402820d..03a58595 100644 --- a/vars/suse.yml +++ b/vars/suse.yml @@ -15,9 +15,7 @@ # limitations under the License. _lxc_hosts_container_image_url_base: "https://download.opensuse.org/repositories/Virtualization:/containers:/images:/openSUSE-Leap-{{ ansible_distribution_version }}/containers/" -# If you want to specify your own image when using SUSE, please override -# in your extra variables lxc_hosts_container_image_url. -_lxc_hosts_container_image_url: "{{ _lxc_hosts_container_image_url_base }}opensuse-leap-image.{{ _lxc_opensuse_image_build_info.stdout }}" +_lxc_hosts_container_image_url: "{{ _lxc_hosts_container_image_url_base }}opensuse-leap-image.x86_64-{{ ansible_distribution_version }}.0.tar.xz" _lxc_cache_map: distro: opensuse