mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Fix inventory parsing so that FQDN can be parsed without throwing ssh
port parsing errors
Fixes problesm introduced by 948d019fef
Adds testcases to defend
This commit is contained in:
@@ -163,6 +163,21 @@ class TestInventory(unittest.TestCase):
|
||||
var = inventory.get_variables('FE80:EF45::12:1')
|
||||
self.assertEqual(var['ansible_ssh_port'], 2222)
|
||||
|
||||
def test_simple_string_fqdn(self):
|
||||
inventory = Inventory('foo.example.com,bar.example.com')
|
||||
hosts = inventory.list_hosts()
|
||||
self.assertEqual(sorted(hosts), sorted(['foo.example.com','bar.example.com']))
|
||||
|
||||
def test_simple_string_fqdn_port(self):
|
||||
inventory = Inventory('foo.example.com:2222,bar.example.com')
|
||||
hosts = inventory.list_hosts()
|
||||
self.assertEqual(sorted(hosts), sorted(['foo.example.com','bar.example.com']))
|
||||
|
||||
def test_simple_string_fqdn_vars(self):
|
||||
inventory = Inventory('foo.example.com:2222,bar.example.com')
|
||||
var = inventory.get_variables('foo.example.com')
|
||||
self.assertEqual(var['ansible_ssh_port'], 2222)
|
||||
|
||||
def test_simple_vars(self):
|
||||
inventory = self.simple_inventory()
|
||||
vars = inventory.get_variables('thor')
|
||||
@@ -254,6 +269,7 @@ class TestInventory(unittest.TestCase):
|
||||
expected2 = ['rtp_a', 'rtp_b']
|
||||
expected3 = ['rtp_a', 'rtp_b', 'rtp_c', 'tri_a', 'tri_b', 'tri_c']
|
||||
expected4 = ['rtp_b', 'orlando' ]
|
||||
expected5 = ['blade-a-1']
|
||||
|
||||
inventory = self.complex_inventory()
|
||||
hosts = inventory.list_hosts("nc[1]")
|
||||
@@ -264,6 +280,8 @@ class TestInventory(unittest.TestCase):
|
||||
self.compare(hosts, expected3, sort=False)
|
||||
hosts = inventory.list_hosts("nc[1-2]:florida[0-1]")
|
||||
self.compare(hosts, expected4, sort=False)
|
||||
hosts = inventory.list_hosts("blade-a-1")
|
||||
self.compare(hosts, expected5, sort=False)
|
||||
|
||||
def test_complex_intersect(self):
|
||||
inventory = self.complex_inventory()
|
||||
|
||||
Reference in New Issue
Block a user