Support multiple IPs per server and robust mapping
All checks were successful
Build and Release / Build Windows Exe (push) Successful in 10s
All checks were successful
Build and Release / Build Windows Exe (push) Successful in 10s
This commit is contained in:
@@ -5,7 +5,7 @@ from wif2ansible.inventory import generate_inventory
|
||||
class TestInventoryKeys(unittest.TestCase):
|
||||
def test_inventory_keys_are_hostnames(self):
|
||||
# Create a server with Ref, Hostname, IP
|
||||
s1 = Server(reference="SERVER_REF_01", hostname="server01", ip_address="192.168.1.10", platform="windows")
|
||||
s1 = Server(reference="SERVER_REF_01", hostname="server01", ip_addresses=["192.168.1.10"], platform="windows")
|
||||
|
||||
# Create a flow matching this server
|
||||
f1 = Flow(flow_id="1", source_ip="192.168.1.10", destination_ip="10.0.0.1", ports=[80])
|
||||
@@ -18,12 +18,12 @@ class TestInventoryKeys(unittest.TestCase):
|
||||
# Verify stricture
|
||||
hosts = inventory['all']['hosts']
|
||||
|
||||
# Key should be REFERENCE "SERVER_REF_01" (or hostname/ip fallback)
|
||||
self.assertIn("SERVER_REF_01", hosts)
|
||||
# Key should be HOSTNAME "server01" (prioritized over Ref)
|
||||
self.assertIn("server01", hosts)
|
||||
self.assertNotIn("192.168.1.10", hosts)
|
||||
|
||||
# Check variables
|
||||
host_vars = hosts["SERVER_REF_01"]
|
||||
host_vars = hosts["server01"]
|
||||
self.assertEqual(host_vars['ansible_host'], "192.168.1.10")
|
||||
self.assertEqual(host_vars['ansible_connection'], "winrm")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user