Commit 8c3206c9 by Jeroen Hoekx

Return a copy of the host variables.

parent 961ccdb2
......@@ -82,7 +82,7 @@ class Inventory(object):
""" Return the variables associated with this host. """
if host in self._variables:
return self._variables[host]
return self._variables[host].copy()
if not self._is_script:
return {}
......
......@@ -219,6 +219,15 @@ class TestInventory(unittest.TestCase):
assert vars == {"hammer":True}
def test_yaml_change_vars(self):
inventory = self.yaml_inventory()
vars = inventory.get_variables('thor')
vars["hammer"] = False
vars = inventory.get_variables('thor')
assert vars == {"hammer":True}
def test_yaml_host_vars(self):
inventory = self.yaml_inventory()
vars = inventory.get_variables('saturn')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment