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:
parent
f6ef560a35
commit
3dfdd010f8
|
@ -368,6 +368,12 @@ class TripleoInventory(object):
|
||||||
if self.ansible_python_interpreter:
|
if self.ansible_python_interpreter:
|
||||||
ret[svc_host]['vars']['ansible_python_interpreter'] = \
|
ret[svc_host]['vars']['ansible_python_interpreter'] = \
|
||||||
self.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
|
return ret
|
||||||
|
|
||||||
|
|
|
@ -164,6 +164,16 @@ class TestInventory(base.TestCase):
|
||||||
self.assertTrue(self.hclient.called_once_with('overcloud',
|
self.assertTrue(self.hclient.called_once_with('overcloud',
|
||||||
'KeystoneURL'))
|
'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):
|
def test_no_ips(self):
|
||||||
for output in self.outputs_data['outputs']:
|
for output in self.outputs_data['outputs']:
|
||||||
if output['output_key'] == 'RoleNetIpMap':
|
if output['output_key'] == 'RoleNetIpMap':
|
||||||
|
@ -216,6 +226,9 @@ class TestInventory(base.TestCase):
|
||||||
'overcloud': {
|
'overcloud': {
|
||||||
'children': ['allovercloud']
|
'children': ['allovercloud']
|
||||||
},
|
},
|
||||||
|
'excluded_overcloud': {
|
||||||
|
'hosts': {}
|
||||||
|
},
|
||||||
'allovercloud': {
|
'allovercloud': {
|
||||||
'children': ['Compute', 'Controller', 'CustomRole'],
|
'children': ['Compute', 'Controller', 'CustomRole'],
|
||||||
'vars': {
|
'vars': {
|
||||||
|
@ -482,6 +495,9 @@ class TestInventory(base.TestCase):
|
||||||
'allovercloud': {}
|
'allovercloud': {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
'excluded_overcloud': {
|
||||||
|
'hosts': {}
|
||||||
|
},
|
||||||
'allovercloud': {'children': {'Compute': {},
|
'allovercloud': {'children': {'Compute': {},
|
||||||
'Controller': {},
|
'Controller': {},
|
||||||
'CustomRole': {}},
|
'CustomRole': {}},
|
||||||
|
|
Loading…
Reference in New Issue