summaryrefslogtreecommitdiff
path: root/lib/ansible/playbook
diff options
context:
space:
mode:
authordevon-mar <devon-mar@users.noreply.github.com>2021-09-10 11:35:41 -0700
committerGitHub <noreply@github.com>2021-09-10 14:35:41 -0400
commit3e7a6222047aae29db4ce0005c0bdf320c7f7918 (patch)
tree35354d017cd80f0db4756946e2eb7078fafb33f9 /lib/ansible/playbook
parent55d448baa7bc11f71f1043dc8d4055efd5c53b6d (diff)
downloadansible-3e7a6222047aae29db4ce0005c0bdf320c7f7918.tar.gz
Fix unexpected exception when a role has an empty argument_specs.yml (#75604)
* Fix role with empty argument_specs.yml * Use try/except and add changelog fragment * Always return a dict * Add test for empty argument_specs key
Diffstat (limited to 'lib/ansible/playbook')
-rw-r--r--lib/ansible/playbook/role/__init__.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/ansible/playbook/role/__init__.py b/lib/ansible/playbook/role/__init__.py
index b88f247896..43d4b27152 100644
--- a/lib/ansible/playbook/role/__init__.py
+++ b/lib/ansible/playbook/role/__init__.py
@@ -294,7 +294,10 @@ class Role(Base, Conditional, Taggable, CollectionSearch):
if self._loader.path_exists(full_path):
# Note: _load_role_yaml() takes care of rebuilding the path.
argument_specs = self._load_role_yaml('meta', main='argument_specs')
- return argument_specs.get('argument_specs', {})
+ try:
+ return argument_specs.get('argument_specs') or {}
+ except AttributeError:
+ return {}
# We did not find the meta/argument_specs.[yml|yaml] file, so use the spec
# dict from the role meta data, if it exists. Ansible 2.11 and later will