From 80eae4a1855bcebb0601f4cf951dc7dad5be3943 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Wed, 29 Aug 2018 11:37:47 +0100 Subject: [PATCH] MNAIO: Add playbook to download saved file-backed VM's With the previously added ability to save file-backed VM's, a user is able to put them onto a web host for storage. We now add a playbook to download the images using the given manifest URL. Change-Id: If1435c70d672cdbacd22df99318c59265362011e --- multi-node-aio/playbooks/download-vms.yml | 58 +++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 multi-node-aio/playbooks/download-vms.yml diff --git a/multi-node-aio/playbooks/download-vms.yml b/multi-node-aio/playbooks/download-vms.yml new file mode 100644 index 00000000..44b7dda5 --- /dev/null +++ b/multi-node-aio/playbooks/download-vms.yml @@ -0,0 +1,58 @@ +--- +# Copyright 2018, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in witing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Download saved files using a given manifest_url + hosts: localhost + connection: local + gather_facts: no + environment: "{{ deployment_environment_variables | default({}) }}" + tags: + - download-vms + vars: + aria2c_parameters: >- + --allow-overwrite=true + --conditional-get=true + --max-connection-per-server=4 + --check-integrity true + --retry-wait=30 + --continue + --quiet + tasks: + - name: Get the manifest file + uri: + url: "{{ manifest_url }}" + return_content: yes + register: _manifest_file + + - set_fact: + _manifest_content: "{{ _manifest_file.content | from_json }}" + + - name: Install aria download manager + package: + name: "aria2" + state: present + + - name: Write artifact URL list + copy: + content: | + {% for item in _manifest_content.files %} + {{ manifest_url | regex_replace('/[^/]*$', '') }}/{{ item.path | basename}} + dir={{ item.path | dirname }} + checksum=sha-1={{ item.checksum }} + {% endfor %} + dest: "/tmp/aria2c.input" + + - name: Download artifacts + command: aria2c --input-file=/tmp/aria2c.input {{ aria2c_parameters }}