def test_ansible_inventory_as_host(self): source = inventory.AnsibleInventory.as_host('localhost foo=bar') target = inventory.AnsibleInventoryHost('localhost', foo='bar') self.assertEquals(source, target) i = inventory.AnsibleInventory(['localhost foo=bar']) self.assertEquals(len(i.global_hosts), 1) self.assertEquals(source, i.global_hosts[0])
def test_simple_inventory_list_and_dict(self): target = inventory.AnsibleInventory( ['localhost', 'localhost2'], sections=[ inventory.AnsibleInventoryGroup('test', ['localhost', 'localhost2']) ]) source = inventory.simple_inventory( ['localhost', 'localhost2'], {"test": ["localhost", "localhost2"]}) self.assertEquals(source.to_string(), target.to_string())
def test_ansible_inventory_api(self): headers = ['localhost foo=bar baz=bar', 'localhost baz=bar foo=bar'] body = ''' [some_group] localhost foo=other 192.168.1.10 [another group] 192.168.1.10 ''' targets = ['%s\n%s' % (h, body) for h in headers] i = inventory.AnsibleInventory( ['localhost foo=bar baz=bar'], sections=[ inventory.AnsibleInventoryGroup( 'some_group', ['localhost foo=other', '192.168.1.10']), inventory.AnsibleInventoryGroup('another group', ['192.168.1.10']) ]) self.assertIn(i.to_string(), targets)
def test_simple_inventory_list(self): target = inventory.AnsibleInventory(['localhost', 'localhost2']) source = inventory.simple_inventory(['localhost', 'localhost2']) self.assertEquals(source.to_string(), target.to_string())