diff --git a/changelogs/fragments/remove-deprecated-vars-syntax.yml b/changelogs/fragments/remove-deprecated-vars-syntax.yml new file mode 100644 index 00000000000..ec9fb9fd2ac --- /dev/null +++ b/changelogs/fragments/remove-deprecated-vars-syntax.yml @@ -0,0 +1,2 @@ +removed_features: + - Removed support for setting the ``vars`` keyword to lists of dictionaries. It is now required to be a single dictionary. diff --git a/lib/ansible/playbook/base.py b/lib/ansible/playbook/base.py index 96c3b9815dc..b046f408cec 100644 --- a/lib/ansible/playbook/base.py +++ b/lib/ansible/playbook/base.py @@ -574,9 +574,7 @@ class FieldAttributeBase: def _load_vars(self, attr, ds): ''' - Vars in a play can be specified either as a dictionary directly, or - as a list of dictionaries. If the later, this method will turn the - list into a single dictionary. + Vars in a play must be specified as a dictionary. ''' def _validate_variable_keys(ds): @@ -588,21 +586,6 @@ class FieldAttributeBase: if isinstance(ds, dict): _validate_variable_keys(ds) return combine_vars(self.vars, ds) - elif isinstance(ds, list): - display.deprecated( - ( - 'Specifying a list of dictionaries for vars is deprecated in favor of ' - 'specifying a dictionary.' - ), - version='2.18' - ) - all_vars = self.vars - for item in ds: - if not isinstance(item, dict): - raise ValueError - _validate_variable_keys(item) - all_vars = combine_vars(all_vars, item) - return all_vars elif ds is None: return {} else: diff --git a/test/sanity/ignore.txt b/test/sanity/ignore.txt index e43a0643da2..3f4ceb1b71d 100644 --- a/test/sanity/ignore.txt +++ b/test/sanity/ignore.txt @@ -196,7 +196,6 @@ test/units/cli/test_data/role_skeleton/README.md pymarkdown:line-length test/integration/targets/find/files/hello_world.gbk no-smart-quotes test/integration/targets/find/files/hello_world.gbk no-unwanted-characters lib/ansible/galaxy/collection/__init__.py pylint:ansible-deprecated-version-comment # 2.18 deprecation -lib/ansible/playbook/base.py pylint:ansible-deprecated-version # 2.18 deprecation lib/ansible/playbook/play.py pylint:ansible-deprecated-version # 2.18 deprecation lib/ansible/playbook/play_context.py pylint:ansible-deprecated-version # 2.18 deprecation lib/ansible/plugins/action/__init__.py pylint:ansible-deprecated-version # 2.18 deprecation diff --git a/test/units/playbook/test_base.py b/test/units/playbook/test_base.py index de0c7ed970a..58253b26542 100644 --- a/test/units/playbook/test_base.py +++ b/test/units/playbook/test_base.py @@ -198,8 +198,7 @@ class TestBase(unittest.TestCase): 'vars': [{'var_2_key': 'var_2_value'}, {'var_1_key': 'var_1_value'}] } - b = self._base_validate(ds) - self.assertEqual(b.vars['var_1_key'], 'var_1_value') + self.assertRaises(AnsibleParserError, self.b.load_data, ds) def test_vars_not_dict_or_list(self): ds = {'environment': [],