From 79eb16e44dc5ac2e88217358ea45ff679270a887 Mon Sep 17 00:00:00 2001 From: Jimmy McCrory Date: Wed, 19 Apr 2017 12:14:52 -0700 Subject: [PATCH] Filter lxc_images list per host To greatly reduce the amount of log noise from skipped tasks, when setting the 'lxc_images' var filter it to only include items that begin with the 'cache_index_item' var. The when clauses in tasks that looped through 'lxc_images' looking for this same match can be removed. Change-Id: I4bf7b32faa9ed0a8cddeb0792f912c0100dbece8 --- tasks/lxc_cache_create.yml | 2 -- tasks/lxc_cache_preparation.yml | 9 ++++++++- tasks/lxc_cache_preparation_systemd_new.yml | 2 -- tasks/lxc_cache_preparation_systemd_old.yml | 2 -- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tasks/lxc_cache_create.yml b/tasks/lxc_cache_create.yml index 70fb0cd1..85108de4 100644 --- a/tasks/lxc_cache_create.yml +++ b/tasks/lxc_cache_create.yml @@ -40,8 +40,6 @@ url: "{{ lxc_image_cache_server }}/{{ item.split(';')[-1] }}/meta.tar.xz" dest: "/tmp/meta.tar.xz" with_items: "{{ lxc_images }}" - when: - - item | match("^{{ cache_index_item }}") - name: Place container metadata unarchive: diff --git a/tasks/lxc_cache_preparation.yml b/tasks/lxc_cache_preparation.yml index 627b5991..733bbc8e 100644 --- a/tasks/lxc_cache_preparation.yml +++ b/tasks/lxc_cache_preparation.yml @@ -26,7 +26,14 @@ - name: Set image index fact set_fact: - lxc_images: "{{ image_index.content.splitlines() }}" + lxc_images: > + {%- set images = [] %} + {%- for image in image_index.content.splitlines() %} + {%- if image | match("^" + cache_index_item) %} + {%- set _ = images.append(image) %} + {%- endif %} + {%- endfor %} + {{- images -}} - include: "lxc_cache_preparation_systemd_{{ (systemd_version.stdout_lines[0].split()[-1] | int > 219) | ternary('new', 'old') }}.yml" diff --git a/tasks/lxc_cache_preparation_systemd_new.yml b/tasks/lxc_cache_preparation_systemd_new.yml index cddfc572..fbfcf327 100644 --- a/tasks/lxc_cache_preparation_systemd_new.yml +++ b/tasks/lxc_cache_preparation_systemd_new.yml @@ -39,5 +39,3 @@ - pull_image.rc != 0 - "'failed' in pull_image.stderr | lower" with_items: "{{ lxc_images }}" - when: - - item | match("^{{ cache_index_item }}") diff --git a/tasks/lxc_cache_preparation_systemd_old.yml b/tasks/lxc_cache_preparation_systemd_old.yml index e61159d7..b2723953 100644 --- a/tasks/lxc_cache_preparation_systemd_old.yml +++ b/tasks/lxc_cache_preparation_systemd_old.yml @@ -126,8 +126,6 @@ retries: 3 delay: 1 with_items: "{{ lxc_images }}" - when: - - item | match("^{{ cache_index_item }}") - name: Place container rootfs unarchive: