From 2eea005773a5d9b2a32c88e1427d839788d00dd6 Mon Sep 17 00:00:00 2001 From: Oliver Walsh Date: Thu, 20 Oct 2022 12:46:35 +0100 Subject: [PATCH] Create entry for empty groups in inventory_rolemap When a group is a child of another group then the child groups role mappings are added to the parent group role mappings. This which fails with a KeyError when the child is an empty group as no mapping is created. Closes-bug: #1994081 Related: rhbz#2089512 Change-Id: I05f4989b0f14d56d3c33f91b3cccb85b729987cb --- filter_plugins/tripleo_upgrade.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/filter_plugins/tripleo_upgrade.py b/filter_plugins/tripleo_upgrade.py index 481c73de..05f5ca27 100644 --- a/filter_plugins/tripleo_upgrade.py +++ b/filter_plugins/tripleo_upgrade.py @@ -49,7 +49,7 @@ def to_inventory_hostmap(data): def to_inventory_rolemap(data): - # Falttens inventory to a group->role mapping + # Flattens inventory to a group->role mapping if isinstance(data, str): inventory = yaml.safe_load(data) else: @@ -65,6 +65,7 @@ def to_inventory_rolemap(data): inventory[group]['vars']['tripleo_role_name'] ] else: + group_role_map[group] = [] if 'children' in inventory[group]: for child in inventory[group]['children']: # Children have not all been flattened yet @@ -73,7 +74,6 @@ def to_inventory_rolemap(data): todo.append(group) break else: - group_role_map[group] = [] for child in inventory[group]['children']: group_role_map[group] += group_role_map[child] group_role_map[group].sort()