Use username from node information if available
Nodepool knows the username that you should ssh with at image build time
and includes this information in the node data. Zuul should use this
username for the executor target.
Change-Id: I1e677061b9fd495b192d25a5825362c81e40d0c6
Depends-On: Ife0daa79f319aea04ed32513f99c73c460156941
diff --git a/tests/unit/test_inventory.py b/tests/unit/test_inventory.py
index 2835d30..04dcb05 100644
--- a/tests/unit/test_inventory.py
+++ b/tests/unit/test_inventory.py
@@ -80,3 +80,24 @@
self.executor_server.release()
self.waitUntilSettled()
+
+ def test_hostvars_inventory(self):
+
+ inventory = self._get_build_inventory('hostvars-inventory')
+
+ all_nodes = ('default', 'fakeuser')
+ self.assertIn('all', inventory)
+ self.assertIn('hosts', inventory['all'])
+ self.assertIn('vars', inventory['all'])
+ for node_name in all_nodes:
+ self.assertIn(node_name, inventory['all']['hosts'])
+ # check if the nodes use the correct username
+ if node_name == 'fakeuser':
+ username = 'fakeuser'
+ else:
+ username = 'zuul'
+ self.assertEqual(
+ inventory['all']['hosts'][node_name]['ansible_user'], username)
+
+ self.executor_server.release()
+ self.waitUntilSettled()