Add excluded group to inventory

This would help filtering nodes from external_*_steps
on delegated groups.

Depends-On: https://review.opendev.org/c/openstack/tripleo-ansible/+/866010

Change-Id: I3a4a9269615e852405f096e3a31985e75b5d7836
(cherry picked from commit 8cd245067e)
This commit is contained in:
Rabi Mishra 2022-09-08 11:24:43 +05:30 committed by Sofer Athlan-Guyot
parent f6ef560a35
commit 3dfdd010f8
2 changed files with 22 additions and 0 deletions

View File

@ -368,6 +368,12 @@ class TripleoInventory(object):
if self.ansible_python_interpreter:
ret[svc_host]['vars']['ansible_python_interpreter'] = \
self.ansible_python_interpreter
excluded_hosts = self.stack_outputs.get('BlacklistedHostnames', {})
excluded_overcloud = ret.setdefault('excluded_overcloud', {})
exclude = excluded_overcloud.setdefault('hosts', {})
for hostname in excluded_hosts:
if hostname:
exclude[hostname] = {}
return ret

View File

@ -164,6 +164,16 @@ class TestInventory(base.TestCase):
self.assertTrue(self.hclient.called_once_with('overcloud',
'KeystoneURL'))
def test_with_excluded_nodes(self):
excluded_output = {
'output_key': 'BlacklistedHostnames',
'output_value': ['cp-0', '', '']
}
self.outputs_data['outputs'].append(excluded_output)
inventory_group = {'hosts': {'cp-0': {}}}
self.assertEquals(inventory_group,
self.inventory.list()['excluded_overcloud'])
def test_no_ips(self):
for output in self.outputs_data['outputs']:
if output['output_key'] == 'RoleNetIpMap':
@ -216,6 +226,9 @@ class TestInventory(base.TestCase):
'overcloud': {
'children': ['allovercloud']
},
'excluded_overcloud': {
'hosts': {}
},
'allovercloud': {
'children': ['Compute', 'Controller', 'CustomRole'],
'vars': {
@ -482,6 +495,9 @@ class TestInventory(base.TestCase):
'allovercloud': {}
}
},
'excluded_overcloud': {
'hosts': {}
},
'allovercloud': {'children': {'Compute': {},
'Controller': {},
'CustomRole': {}},