Introduce comics and cartoons to test yaml groups defined on a per-node basis
This commit is contained in:
parent
aa13d23307
commit
eb63b9e899
2 changed files with 66 additions and 5 deletions
|
@ -221,15 +221,14 @@ class TestInventory(unittest.TestCase):
|
||||||
def test_yaml(self):
|
def test_yaml(self):
|
||||||
inventory = self.yaml_inventory()
|
inventory = self.yaml_inventory()
|
||||||
hosts = inventory.list_hosts()
|
hosts = inventory.list_hosts()
|
||||||
print hosts
|
expected_hosts=['garfield', 'goofy', 'hera', 'jerry', 'jupiter', 'loki', 'mars', 'mickey', 'odie', 'odin', 'poseidon', 'saturn', 'thor', 'tom', 'zeus']
|
||||||
expected_hosts=['jupiter', 'saturn', 'mars', 'zeus', 'hera', 'poseidon', 'thor', 'odin', 'loki']
|
|
||||||
self.compare(hosts, expected_hosts)
|
self.compare(hosts, expected_hosts)
|
||||||
|
|
||||||
def test_yaml_all(self):
|
def test_yaml_all(self):
|
||||||
inventory = self.yaml_inventory()
|
inventory = self.yaml_inventory()
|
||||||
hosts = inventory.list_hosts('all')
|
hosts = inventory.list_hosts('all')
|
||||||
|
|
||||||
expected_hosts=['jupiter', 'saturn', 'mars', 'zeus', 'hera', 'poseidon', 'thor', 'odin', 'loki']
|
expected_hosts=['garfield', 'goofy', 'hera', 'jerry', 'jupiter', 'loki', 'mars', 'mickey', 'odie', 'odin', 'poseidon', 'saturn', 'thor', 'tom', 'zeus']
|
||||||
self.compare(hosts, expected_hosts)
|
self.compare(hosts, expected_hosts)
|
||||||
|
|
||||||
def test_yaml_norse(self):
|
def test_yaml_norse(self):
|
||||||
|
@ -323,3 +322,29 @@ class TestInventory(unittest.TestCase):
|
||||||
assert 'group_names' in vars
|
assert 'group_names' in vars
|
||||||
assert sorted(vars['group_names']) == [ 'norse', 'ruler' ]
|
assert sorted(vars['group_names']) == [ 'norse', 'ruler' ]
|
||||||
|
|
||||||
|
def test_yaml_some_animals(self):
|
||||||
|
inventory = self.yaml_inventory()
|
||||||
|
hosts = inventory.list_hosts("cat:mouse")
|
||||||
|
expected_hosts=['garfield', 'jerry', 'mickey', 'tom']
|
||||||
|
self.compare(hosts, expected_hosts)
|
||||||
|
|
||||||
|
def test_yaml_comic(self):
|
||||||
|
inventory = self.yaml_inventory()
|
||||||
|
hosts = inventory.list_hosts("comic")
|
||||||
|
expected_hosts=['garfield', 'odie']
|
||||||
|
self.compare(hosts, expected_hosts)
|
||||||
|
|
||||||
|
def test_yaml_orange(self):
|
||||||
|
inventory = self.yaml_inventory()
|
||||||
|
hosts = inventory.list_hosts("orange")
|
||||||
|
expected_hosts=['garfield', 'goofy']
|
||||||
|
self.compare(hosts, expected_hosts)
|
||||||
|
|
||||||
|
def test_yaml_garfield_vars(self):
|
||||||
|
inventory = self.yaml_inventory()
|
||||||
|
vars = inventory.get_variables('garfield')
|
||||||
|
assert vars == {'ears': 'pointy',
|
||||||
|
'inventory_hostname': 'garfield',
|
||||||
|
'group_names': ['cat', 'comic', 'orange'],
|
||||||
|
'nose': 'pink'}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
- jupiter
|
- jupiter
|
||||||
- host: saturn
|
- host: saturn
|
||||||
groups: [ multiple ]
|
|
||||||
vars:
|
vars:
|
||||||
moon: titan
|
moon: titan
|
||||||
moon2: enceladus
|
moon2: enceladus
|
||||||
|
@ -10,12 +9,12 @@
|
||||||
- host: mars
|
- host: mars
|
||||||
|
|
||||||
- host: zeus
|
- host: zeus
|
||||||
groups: [ greek, ruler ]
|
|
||||||
vars:
|
vars:
|
||||||
- ansible_ssh_port: 3001
|
- ansible_ssh_port: 3001
|
||||||
|
|
||||||
- group: greek
|
- group: greek
|
||||||
hosts:
|
hosts:
|
||||||
|
- zeus
|
||||||
- hera
|
- hera
|
||||||
- poseidon
|
- poseidon
|
||||||
vars:
|
vars:
|
||||||
|
@ -32,4 +31,41 @@
|
||||||
|
|
||||||
- group: ruler
|
- group: ruler
|
||||||
hosts:
|
hosts:
|
||||||
|
- zeus
|
||||||
- odin
|
- odin
|
||||||
|
|
||||||
|
- group: multiple
|
||||||
|
hosts:
|
||||||
|
- saturn
|
||||||
|
|
||||||
|
- host: garfield
|
||||||
|
groups: [ comic, cat, orange ]
|
||||||
|
vars:
|
||||||
|
- nose: pink
|
||||||
|
|
||||||
|
- host: odie
|
||||||
|
groups: [ comic, dog, yellow ]
|
||||||
|
|
||||||
|
- host: mickey
|
||||||
|
groups: [ cartoon, mouse, red ]
|
||||||
|
|
||||||
|
- host: goofy
|
||||||
|
groups: [ cartoon, dog, orange ]
|
||||||
|
|
||||||
|
- host: tom
|
||||||
|
groups: [ cartoon, cat, gray ]
|
||||||
|
|
||||||
|
- host: jerry
|
||||||
|
groups: [ cartoon, mouse, brown ]
|
||||||
|
|
||||||
|
- group: cat
|
||||||
|
vars:
|
||||||
|
- ears: pointy
|
||||||
|
|
||||||
|
- group: dog
|
||||||
|
vars:
|
||||||
|
- ears: flappy
|
||||||
|
|
||||||
|
- group: mouse
|
||||||
|
vars:
|
||||||
|
- ears: round
|
||||||
|
|
Loading…
Add table
Reference in a new issue