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
pull/15942/merge
James Cammarata 8 years ago
parent 5984e3ee9b
commit f36926f8d3

@ -34,6 +34,12 @@ from ansible.playbook.taggable import Taggable
from ansible.template import Templar from ansible.template import Templar
from ansible.utils.path import unfrackpath from ansible.utils.path import unfrackpath
try:
from __main__ import display
except ImportError:
from ansible.utils.display import Display
display = Display()
__all__ = ['RoleDefinition'] __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 # or make this list more automatic in some way so we don't have to
# remember to update it manually. # remember to update it manually.
if key not in base_attribute_names or key in ('connection', 'port', 'remote_user'): 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 # this key does not match a field attribute, so it must be a role param
role_params[key] = value role_params[key] = value
else: else:

Loading…
Cancel
Save