From 2d42633a434afcaae41cfb5131ad0e4dfae7ddc3 Mon Sep 17 00:00:00 2001 From: Attila Darazs Date: Thu, 8 Dec 2016 19:05:38 +0100 Subject: [PATCH] Fetch images in a standalone role This functionality is useful in non-libvirt environments, so separate it and include it with the new Ansible 2.2 include_role method. Change-Id: I2ed5dd8115cce012a007b7d791777b052034a17a --- roles/fetch-images/meta/main.yml | 2 ++ .../tasks/fetch.yml} | 17 --------------- roles/fetch-images/tasks/main.yml | 21 +++++++++++++++++++ roles/libvirt/setup/undercloud/tasks/main.yml | 7 +++---- 4 files changed, 26 insertions(+), 21 deletions(-) create mode 100644 roles/fetch-images/meta/main.yml rename roles/{libvirt/setup/undercloud/tasks/fetch_image.yml => fetch-images/tasks/fetch.yml} (84%) create mode 100644 roles/fetch-images/tasks/main.yml diff --git a/roles/fetch-images/meta/main.yml b/roles/fetch-images/meta/main.yml new file mode 100644 index 000000000..9d17fb78d --- /dev/null +++ b/roles/fetch-images/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - common diff --git a/roles/libvirt/setup/undercloud/tasks/fetch_image.yml b/roles/fetch-images/tasks/fetch.yml similarity index 84% rename from roles/libvirt/setup/undercloud/tasks/fetch_image.yml rename to roles/fetch-images/tasks/fetch.yml index 08c6d60db..588721f57 100644 --- a/roles/libvirt/setup/undercloud/tasks/fetch_image.yml +++ b/roles/fetch-images/tasks/fetch.yml @@ -1,20 +1,3 @@ -# Fetching the undercloud images can take a long time. This -# tasklist caches images in `{{ image_cache_dir }}` if an image is -# (a) downloaded successfully and (b) successfully verifies against -# the checksum. Images are cached using the checksum as the filename, -# and subsequent playbook runs will use the cached copy rather than -# trying to fetch the remote copy. - -# This checks that the image_cache_dir directory exists. When running -# the full quickstart, this is created by the provision/remote role. -# If you are running this role by itself, you will need to ensure that -# either the directory exists ahead of time or that ansible has the -# permissions to create the directory. -- name: Ensure image cache directory exists - file: - path: "{{ image_cache_dir }}" - state: directory - # Set some convenience variables here to avoid boilerplate code # elsewhere in this file. These are all set unconditionally to avoid # any cruft leftover from a previous call to this file. diff --git a/roles/fetch-images/tasks/main.yml b/roles/fetch-images/tasks/main.yml new file mode 100644 index 000000000..f00a15600 --- /dev/null +++ b/roles/fetch-images/tasks/main.yml @@ -0,0 +1,21 @@ +# Fetching the undercloud images can take a long time. This +# role caches images in `{{ image_cache_dir }}` if an image is +# (a) downloaded successfully and (b) successfully verifies against +# the checksum. Images are cached using the checksum as the filename, +# and subsequent playbook runs will use the cached copy rather than +# trying to fetch the remote copy. + +# This checks that the image_cache_dir directory exists. When running +# the full quickstart, this is created by the provision/remote role. +# If you are running this role by itself, you will need to ensure that +# either the directory exists ahead of time or that ansible has the +# permissions to create the directory. +- name: Ensure image cache directory exists + file: + path: "{{ image_cache_dir }}" + state: directory + +- include: fetch.yml + vars: + image: "{{ item }}" + with_items: "{{ images }}" diff --git a/roles/libvirt/setup/undercloud/tasks/main.yml b/roles/libvirt/setup/undercloud/tasks/main.yml index 77641f1b4..3d9ec49cc 100644 --- a/roles/libvirt/setup/undercloud/tasks/main.yml +++ b/roles/libvirt/setup/undercloud/tasks/main.yml @@ -31,10 +31,9 @@ # Conditionally include a playbook for all the images specified # in options that downloads, cache and extract if tar archived # only if the images aren't already in volume pool - - include: fetch_image.yml - vars: - image: "{{ item }}" - with_items: "{{ images }}" + - name: Fetch the images + include_role: + name: fetch-images # Conditionally include a playbook for all the images specified # in options that updates images to the latest delorean version