diff options
author | Daniel Hokka Zakrisson <daniel@hozac.com> | 2013-03-01 23:34:14 +0100 |
---|---|---|
committer | Daniel Hokka Zakrisson <daniel@hozac.com> | 2013-03-01 23:34:14 +0100 |
commit | 1f8805d9e09be08122af272483cd340b38ba5324 (patch) | |
tree | d5c1034ca04220f14534ac1d90260a113de74b8b /test | |
parent | vars_loader should get the path to the inventory + vars_plugins (diff) | |
download | ansible-1f8805d9e09be08122af272483cd340b38ba5324.tar.xz ansible-1f8805d9e09be08122af272483cd340b38ba5324.zip |
Add some tests for directory-based inventory
Diffstat (limited to 'test')
-rw-r--r-- | test/TestInventory.py | 15 | ||||
-rw-r--r-- | test/inventory_dir/0hosts | 3 | ||||
-rw-r--r-- | test/inventory_dir/1mythology | 6 | ||||
-rw-r--r-- | test/inventory_dir/2levels | 6 |
4 files changed, 30 insertions, 0 deletions
diff --git a/test/TestInventory.py b/test/TestInventory.py index 1f2cd02c21..55706bba6b 100644 --- a/test/TestInventory.py +++ b/test/TestInventory.py @@ -13,6 +13,7 @@ class TestInventory(unittest.TestCase): self.large_range_inventory_file = os.path.join(self.test_dir, 'large_range') self.complex_inventory_file = os.path.join(self.test_dir, 'complex_hosts') self.inventory_script = os.path.join(self.test_dir, 'inventory_api.py') + self.inventory_dir = os.path.join(self.test_dir, 'inventory_dir') os.chmod(self.inventory_script, 0755) @@ -39,6 +40,9 @@ class TestInventory(unittest.TestCase): def complex_inventory(self): return Inventory(self.complex_inventory_file) + def dir_inventory(self): + return Inventory(self.inventory_dir) + all_simple_hosts=['jupiter', 'saturn', 'zeus', 'hera', 'cerberus001','cerberus002','cerberus003', 'cottus99', 'cottus100', @@ -288,3 +292,14 @@ class TestInventory(unittest.TestCase): assert vars == {'inventory_hostname': 'zeus', 'inventory_hostname_short': 'zeus', 'group_names': ['greek', 'major-god']} + + def test_dir_inventory(self): + inventory = self.dir_inventory() + vars = inventory.get_variables('zeus') + + print "VARS=%s" % vars + + assert vars == {'inventory_hostname': 'zeus', + 'inventory_hostname_short': 'zeus', + 'group_names': ['greek', 'major-god', 'ungrouped'], + 'var_a': '1'} diff --git a/test/inventory_dir/0hosts b/test/inventory_dir/0hosts new file mode 100644 index 0000000000..27fc46e853 --- /dev/null +++ b/test/inventory_dir/0hosts @@ -0,0 +1,3 @@ +zeus var_a=2 +morpheus +thor diff --git a/test/inventory_dir/1mythology b/test/inventory_dir/1mythology new file mode 100644 index 0000000000..43fa181bd5 --- /dev/null +++ b/test/inventory_dir/1mythology @@ -0,0 +1,6 @@ +[greek] +zeus +morpheus + +[norse] +thor diff --git a/test/inventory_dir/2levels b/test/inventory_dir/2levels new file mode 100644 index 0000000000..22f06bcd43 --- /dev/null +++ b/test/inventory_dir/2levels @@ -0,0 +1,6 @@ +[major-god] +zeus var_a=1 +thor + +[minor-god] +morpheus |