Moved the _inventory.clear_group_dict_cache() from creating a group w… (#17766)
* Moved the _inventory.clear_group_dict_cache() from creating a group which doesn't exist, to adding members to the group.
* Update __init__.py
Update to use changed: block to catch all changes for cache clear as suggested
(cherry picked from commit b91d4d884d
)
This commit is contained in:
parent
35e198a616
commit
c2f9846278
1 changed files with 4 additions and 3 deletions
|
@ -624,9 +624,6 @@ class StrategyBase:
|
||||||
group_name = result_item.get('add_group')
|
group_name = result_item.get('add_group')
|
||||||
new_group = self._inventory.get_group(group_name)
|
new_group = self._inventory.get_group(group_name)
|
||||||
if not new_group:
|
if not new_group:
|
||||||
# clear cache of group dict, which is used in magic host variables
|
|
||||||
self._inventory.clear_group_dict_cache()
|
|
||||||
|
|
||||||
# create the new group and add it to inventory
|
# create the new group and add it to inventory
|
||||||
new_group = Group(name=group_name)
|
new_group = Group(name=group_name)
|
||||||
self._inventory.add_group(new_group)
|
self._inventory.add_group(new_group)
|
||||||
|
@ -641,6 +638,10 @@ class StrategyBase:
|
||||||
new_group.add_host(real_host)
|
new_group.add_host(real_host)
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
|
if changed:
|
||||||
|
# clear cache of group dict, which is used in magic host variables
|
||||||
|
self._inventory.clear_group_dict_cache()
|
||||||
|
|
||||||
return changed
|
return changed
|
||||||
|
|
||||||
def _load_included_file(self, included_file, iterator, is_handler=False):
|
def _load_included_file(self, included_file, iterator, is_handler=False):
|
||||||
|
|
Loading…
Reference in a new issue