|
|
|
@ -85,13 +85,13 @@ class TestInventory(unittest.TestCase):
|
|
|
|
|
inventory = self.simple_inventory()
|
|
|
|
|
vars = inventory.get_variables('thor')
|
|
|
|
|
|
|
|
|
|
assert vars == {}
|
|
|
|
|
assert vars == {'group_names': ['norse']}
|
|
|
|
|
|
|
|
|
|
def test_simple_port(self):
|
|
|
|
|
inventory = self.simple_inventory()
|
|
|
|
|
vars = inventory.get_variables('hera')
|
|
|
|
|
|
|
|
|
|
assert vars == {'ansible_ssh_port': 3000}
|
|
|
|
|
assert vars == {'ansible_ssh_port': 3000, 'group_names': ['greek']}
|
|
|
|
|
|
|
|
|
|
### Inventory API tests
|
|
|
|
|
|
|
|
|
@ -146,7 +146,7 @@ class TestInventory(unittest.TestCase):
|
|
|
|
|
inventory = self.script_inventory()
|
|
|
|
|
vars = inventory.get_variables('thor')
|
|
|
|
|
|
|
|
|
|
assert vars == {"hammer":True}
|
|
|
|
|
assert vars == {"hammer":True, 'group_names': ['norse']}
|
|
|
|
|
|
|
|
|
|
### Tests for yaml inventory file
|
|
|
|
|
|
|
|
|
@ -205,7 +205,7 @@ class TestInventory(unittest.TestCase):
|
|
|
|
|
inventory = self.yaml_inventory()
|
|
|
|
|
vars = inventory.get_variables('thor')
|
|
|
|
|
|
|
|
|
|
assert vars == {"hammer":True}
|
|
|
|
|
assert vars == {"hammer":True, 'group_names': ['norse']}
|
|
|
|
|
|
|
|
|
|
def test_yaml_change_vars(self):
|
|
|
|
|
inventory = self.yaml_inventory()
|
|
|
|
@ -214,19 +214,30 @@ class TestInventory(unittest.TestCase):
|
|
|
|
|
vars["hammer"] = False
|
|
|
|
|
|
|
|
|
|
vars = inventory.get_variables('thor')
|
|
|
|
|
assert vars == {"hammer":True}
|
|
|
|
|
assert vars == {"hammer":True, 'group_names': ['norse']}
|
|
|
|
|
|
|
|
|
|
def test_yaml_host_vars(self):
|
|
|
|
|
inventory = self.yaml_inventory()
|
|
|
|
|
vars = inventory.get_variables('saturn')
|
|
|
|
|
|
|
|
|
|
assert vars == {"moon":"titan", "moon2":"enceladus"}
|
|
|
|
|
assert vars == {"moon":"titan",
|
|
|
|
|
"moon2":"enceladus",
|
|
|
|
|
'group_names': ['multiple']}
|
|
|
|
|
|
|
|
|
|
def test_yaml_port(self):
|
|
|
|
|
inventory = self.yaml_inventory()
|
|
|
|
|
vars = inventory.get_variables('hera')
|
|
|
|
|
|
|
|
|
|
assert vars == {'ansible_ssh_port': 3000, 'ntp_server': 'olympus.example.com'}
|
|
|
|
|
assert vars == {'ansible_ssh_port': 3000,
|
|
|
|
|
'ntp_server': 'olympus.example.com',
|
|
|
|
|
'group_names': ['greek']}
|
|
|
|
|
|
|
|
|
|
def test_yaml_multiple_groups(self):
|
|
|
|
|
inventory = self.yaml_inventory()
|
|
|
|
|
vars = inventory.get_variables('odin')
|
|
|
|
|
|
|
|
|
|
assert 'group_names' in vars
|
|
|
|
|
assert sorted(vars['group_names']) == [ 'norse', 'ruler' ]
|
|
|
|
|
|
|
|
|
|
### Test Runner class method
|
|
|
|
|
|
|
|
|
|