Fix ansible-generate-inventory action

ansible-generate-inventory action raises Exception
when 'ansible_python_interpreter' input is passed to it.

This patch fixes it and also update unit test to cover
missing part.

Adjusts Unit test for stable/stein as [1] is not in
stable/stein.

[1] https://review.opendev.org/#/c/663466/

Closes-Bug: #1838536
Depends-On: https://review.opendev.org/#/c/674530/
Change-Id: Ie41ba6de1170a9c9ffc94889e47bce9ef1200521
(cherry picked from commit 6a35576e9e)
This commit is contained in:
yatinkarel 2019-07-31 21:01:05 +05:30 committed by yatin
parent 5525d4d6d2
commit df8f0243d0
2 changed files with 21 additions and 2 deletions

View File

@ -289,14 +289,15 @@ class TripleoInventory(object):
service_children = [role for role in roles
if ret.get(role) is not None]
if service_children:
ret[service.lower()] = {
svc_host = service.lower()
ret[svc_host] = {
'children': self._hosts(service_children),
'vars': {
'ansible_ssh_user': self.ansible_ssh_user
}
}
if self.ansible_python_interpreter:
ret[role]['vars']['ansible_python_interpreter'] = \
ret[svc_host]['vars']['ansible_python_interpreter'] = \
self.ansible_python_interpreter
if not self.hosts_format_dict:

View File

@ -280,6 +280,24 @@ class TestInventory(base.TestCase):
'container_cli': 'podman',
'ctlplane_vip': 'x.x.x.4',
'redis_vip': 'x.x.x.6'}},
'sa': {'children': ['Controller'],
'vars': {'ansible_ssh_user': 'my-custom-admin',
'ansible_python_interpreter': 'foo'}},
'sb': {'children': ['Controller'],
'vars': {'ansible_ssh_user': 'my-custom-admin',
'ansible_python_interpreter': 'foo'}},
'sd': {'children': ['Compute'],
'vars': {'ansible_ssh_user': 'my-custom-admin',
'ansible_python_interpreter': 'foo'}},
'se': {'children': ['Compute'],
'vars': {'ansible_ssh_user': 'my-custom-admin',
'ansible_python_interpreter': 'foo'}},
'sg': {'children': ['CustomRole'],
'vars': {'ansible_ssh_user': 'my-custom-admin',
'ansible_python_interpreter': 'foo'}},
'sh': {'children': ['CustomRole'],
'vars': {'ansible_ssh_user': 'my-custom-admin',
'ansible_python_interpreter': 'foo'}},
'Undercloud': {
'hosts': ['undercloud'],
'vars': {'ansible_connection': 'ssh',