From f36926f8d3368de4610ea285645e7e5f0fae0f43 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Fri, 18 Nov 2016 22:15:55 -0600 Subject: [PATCH] With role params also keep special params in the ds as well as params With 2.0, we decided to create a special list of param names which were taken out of the role data structure and stored as params instead (connection, port, and remote_user). This causes problems with inheritance of these params, so we are now deprecating that while also keeping those keys in the ds so they are brought in as attributes on the Role correctly. Fixes #17395 --- lib/ansible/playbook/role/definition.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/ansible/playbook/role/definition.py b/lib/ansible/playbook/role/definition.py index 6b78a1b3498..32a1bdca58b 100644 --- a/lib/ansible/playbook/role/definition.py +++ b/lib/ansible/playbook/role/definition.py @@ -34,6 +34,12 @@ from ansible.playbook.taggable import Taggable from ansible.template import Templar from ansible.utils.path import unfrackpath +try: + from __main__ import display +except ImportError: + from ansible.utils.display import Display + display = Display() + __all__ = ['RoleDefinition'] @@ -197,6 +203,11 @@ class RoleDefinition(Base, Become, Conditional, Taggable): # or make this list more automatic in some way so we don't have to # remember to update it manually. if key not in base_attribute_names or key in ('connection', 'port', 'remote_user'): + if key in ('connection', 'port', 'remote_user'): + display.deprecated("Using '%s' as a role param has been deprecated. " % key + \ + "In the future, these values should be entered in the `vars:` " + \ + "section for roles, but for now we'll store it as both a param and an attribute.") + role_def[key] = value # this key does not match a field attribute, so it must be a role param role_params[key] = value else: