示例#1
0
    def test_ansible_inventory_headding_mangling(self):
        g = inventory.InventoryGroup('[foobar]')
        self.assertEquals(g.heading, '[foobar]')
        self.assertEquals(g.name, 'foobar')

        g = inventory.InventoryGroup('foobar]')
        self.assertEquals(g.heading, '[foobar]')
        self.assertEquals(g.name, 'foobar')

        g = inventory.InventoryGroup('foobar')
        self.assertEquals(g.heading, '[foobar]')
        self.assertEquals(g.name, 'foobar')
示例#2
0
    def test_ansible_inventory_group_items(self):
        base = 'localhost foo=bar bar=baz'
        h = inventory.InventoryHost.from_string(base)

        g = inventory.InventoryGroup('[foobar]', [base])

        self.assertEquals(len(g.items), 1)
        self.assertEquals(g.items[0], h)

        g2 = inventory.InventoryGroup('[foobar]', [h])

        self.assertEquals(len(g2.items), 1)
        self.assertEquals(g.items[0], g2.items[0])
示例#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)
示例#4
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())
示例#5
0
 def test_ansible_inventory_group_set_name(self):
     g = inventory.InventoryGroup('[foobar]')
     g.name = 'FOOBAR'
     self.assertEquals(g.name, 'FOOBAR')
     self.assertEquals(g.heading, '[FOOBAR]')
示例#6
0
 def test_ansible_inventory_group_name(self):
     g = inventory.InventoryGroup('[foobar]')
     self.assertEquals(g.heading, '[foobar]')
     self.assertEquals(g.name, 'foobar')