Fix multiple var files combining (followup to #36357)

(cherry picked from commit 2e62e36590)
pull/43346/head
Andrey Laguta 7 years ago committed by Matt Clay
parent 49d81006df
commit a0138e5461

@ -249,6 +249,28 @@ class TestRole(unittest.TestCase):
self.assertEqual(r._default_vars, dict(foo='bar')) self.assertEqual(r._default_vars, dict(foo='bar'))
self.assertEqual(r._role_vars, dict(foo='bam')) self.assertEqual(r._role_vars, dict(foo='bam'))
@patch('ansible.playbook.role.definition.unfrackpath', mock_unfrackpath_noop)
def test_load_role_with_vars_nested_dirs_combined(self):
fake_loader = DictDataLoader({
"/etc/ansible/roles/foo_vars/defaults/main/foo/bar.yml": """
foo: bar
a: 1
""",
"/etc/ansible/roles/foo_vars/defaults/main/bar/foo.yml": """
foo: bam
b: 2
""",
})
mock_play = MagicMock()
mock_play.ROLE_CACHE = {}
i = RoleInclude.load('foo_vars', play=mock_play, loader=fake_loader)
r = Role.load(i, play=mock_play)
self.assertEqual(r._default_vars, dict(foo='bar', a=1, b=2))
@patch('ansible.playbook.role.definition.unfrackpath', mock_unfrackpath_noop) @patch('ansible.playbook.role.definition.unfrackpath', mock_unfrackpath_noop)
def test_load_role_with_vars_dir_vs_file(self): def test_load_role_with_vars_dir_vs_file(self):

Loading…
Cancel
Save