Esempio n. 1
0
    def test_ansible_inventory_as_host(self):
        source = inventory.Inventory.as_host('localhost foo=bar')
        target = inventory.InventoryHost('localhost', foo='bar')

        self.assertEquals(source, target)

        i = inventory.Inventory(['localhost foo=bar'])

        self.assertEquals(len(i.global_hosts), 1)
        self.assertEquals(source, i.global_hosts[0])
Esempio n. 2
0
    def test_simple_inventory_list_and_dict(self):
        target = inventory.Inventory(['localhost', 'localhost2'],
                                     sections=[
                                         inventory.InventoryGroup(
                                             'test',
                                             ['localhost', 'localhost2'])
                                     ])

        source = inventory.simple_inventory(
            ['localhost', 'localhost2'], {"test": ["localhost", "localhost2"]})

        self.assertEquals(source.to_string(), target.to_string())
Esempio n. 3
0
    def test_ansible_inventory_api(self):
        target = '''localhost foo=bar baz=bar

[some_group]
localhost foo=other
192.168.1.10

[another group]
192.168.1.10

'''
        i = inventory.Inventory(
            ['localhost foo=bar baz=bar'],
            sections=[
                inventory.InventoryGroup(
                    'some_group', ['localhost foo=other', '192.168.1.10']),
                inventory.InventoryGroup('another group', ['192.168.1.10'])
            ])

        self.assertEquals(i.to_string(), target)
Esempio n. 4
0
    def test_simple_inventory_list(self):
        target = inventory.Inventory(['localhost', 'localhost2'])
        source = inventory.simple_inventory(['localhost', 'localhost2'])

        self.assertEquals(source.to_string(), target.to_string())