Force local connection for localhost
Starting with Ansible 2.9.10, the "Collecting node facts" task in bifrost-configdrives-dynamic can fail because it tries to SSH to localhost, which may not be possible in some environments, such as Bifrost deployed as a container by Kolla. Change-Id: I1ed19e325db9396ff6b250e14c967ce90c785201 Story: 2008260 Task: 41118
This commit is contained in:
parent
a04b285434
commit
a6c56c6647
@ -164,7 +164,7 @@ def _parse_config():
|
||||
|
||||
|
||||
def _prepare_inventory():
|
||||
hostvars = {}
|
||||
hostvars = {"127.0.0.1": {"ansible_connection": "local"}}
|
||||
groups = {}
|
||||
groups.update({'baremetal': {'hosts': []}})
|
||||
groups.update({'localhost': {'hosts': ["127.0.0.1"]}})
|
||||
|
@ -53,6 +53,7 @@ class TestBifrostInventoryFunctional(base.TestCase):
|
||||
"host_groups": ["baremetal", "nova"]}}""".replace('\n', '')
|
||||
(groups, hostvars) = utils.bifrost_data_conversion(
|
||||
yaml.safe_dump(json.loads(str(expected_hostvars))))
|
||||
del hostvars['127.0.0.1']
|
||||
self.assertDictEqual(json.loads(str(expected_hostvars)), hostvars)
|
||||
|
||||
def test_minimal_json(self):
|
||||
@ -66,4 +67,5 @@ ipmi_password":"ADMIN"}},"driver":"ipmi"}}""".replace('\n', '')
|
||||
ipmi_password":"ADMIN"}},"driver":"ipmi","addressing_mode":
|
||||
"dhcp","host_groups": ["baremetal"]}}""".replace('\n', '')
|
||||
(groups, hostvars) = utils.bifrost_data_conversion(input_json)
|
||||
del hostvars['127.0.0.1']
|
||||
self.assertDictEqual(json.loads(str(expected_json)), hostvars)
|
||||
|
@ -33,7 +33,8 @@ class TestBifrostInventoryUnit(base.TestCase):
|
||||
(groups, hostvars) = inventory._prepare_inventory()
|
||||
self.assertIn("baremetal", groups)
|
||||
self.assertIn("localhost", groups)
|
||||
self.assertDictEqual(hostvars, {})
|
||||
self.assertDictEqual(
|
||||
hostvars, {'127.0.0.1': {'ansible_connection': 'local'}})
|
||||
localhost_value = dict(hosts=["127.0.0.1"])
|
||||
self.assertDictEqual(localhost_value, groups['localhost'])
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user