From 30b72fcdd9999a02b8661233e78897358a9d4a17 Mon Sep 17 00:00:00 2001 From: Jonathan Rosser Date: Wed, 25 Oct 2023 16:26:00 +0100 Subject: [PATCH] Only create certificate destination directories once. If installing several certs or keys to a target the destination directory creation task is run once for each list item even if it is the same directory every time. This patch filters the list of targets and reduces the list of target directories to a unique list, reducing the number of loop iterations required. Change-Id: I7432463dfa067afed2f46874119378bfdf96639c --- tasks/main_certs.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/main_certs.yml b/tasks/main_certs.yml index 9b61fb1..cf64cc2 100644 --- a/tasks/main_certs.yml +++ b/tasks/main_certs.yml @@ -33,16 +33,16 @@ - name: Create certificate destination directories file: - path: "{{ install.item.dest | dirname }}" + path: "{{ install }}" state: directory mode: "0755" - loop: "{{ _cert_slurp.results }}" + loop: "{{ _cert_slurp.results | map(attribute='item') | map(attribute='dest') | map('dirname') | unique }}" loop_control: loop_var: install label: "{{ loop_label | to_json }}" vars: loop_label: - path: "{{ install.item.dest | dirname }}" + path: "{{ install }}" state: directory mode: '0755'