From 63363abdbf094f4fc0a5f52412661563b6bede36 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Wed, 21 Dec 2022 13:41:10 +0100 Subject: [PATCH] Prevent bootstrap failure when all roles/collections are overriden At the moment we assume that scenario when all roles or collections provided by ansible-role/collection-requirements won't be overwritten. As if they do, previous set_fact will be skipped and galaxy_collections_list/clone_roles will remain undefined. To avoid failure and to allow to fully override roles/collections we define default for the task that aims to merge default items with user-provided ones. Change-Id: I86d44499073f0571a529d81ed3be713996e5f339 --- scripts/get-ansible-collection-requirements.yml | 2 +- scripts/get-ansible-role-requirements.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/get-ansible-collection-requirements.yml b/scripts/get-ansible-collection-requirements.yml index e71108fa73..aca7c1a8aa 100644 --- a/scripts/get-ansible-collection-requirements.yml +++ b/scripts/get-ansible-collection-requirements.yml @@ -42,7 +42,7 @@ - name: Append user collections to filtered required collections set_fact: - galaxy_collections_list: "{{ galaxy_collections_list + [ item ] }}" + galaxy_collections_list: "{{ (galaxy_collections_list | default([])) + [ item ] }}" with_items: "{{ user_collections.collections }}" when: - user_collections.collections is defined diff --git a/scripts/get-ansible-role-requirements.yml b/scripts/get-ansible-role-requirements.yml index d988084e85..e7aa099fe9 100644 --- a/scripts/get-ansible-role-requirements.yml +++ b/scripts/get-ansible-role-requirements.yml @@ -132,7 +132,7 @@ - name: Append user overridden roles set_fact: - clone_roles: "{{ clone_roles + user_roles }}" + clone_roles: "{{ (clone_roles | default([])) + user_roles }}" - name: Clone git repos block: