From 5c70fb05d8e93a639c5e875f2b28270d541de7a8 Mon Sep 17 00:00:00 2001 From: Andy McCrae Date: Wed, 4 Jul 2018 12:22:02 +0100 Subject: [PATCH] Fix config_template to work with Ansible 2.6 In Ansible 2.6 the copy module now recognizes the "_original_basename" option and not the "original_basename" option. In order for this module to work with versions less than 2.6.0 and 2.6.0+ we need to allow an if statement based on the version of Ansible being used. Change-Id: I3f7a12dec77ea6e8e3c9fcae6ce9c162df57e50c (cherry picked from commit fcf669b78c9266212a07a0a1caef6ff73a7cef73) --- action/config_template.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/action/config_template.py b/action/config_template.py index 8714749b..725e3b30 100644 --- a/action/config_template.py +++ b/action/config_template.py @@ -41,6 +41,8 @@ from ansible.module_utils._text import to_bytes, to_text from ansible import constants as C from ansible import errors from ansible.parsing.yaml.dumper import AnsibleDumper +from distutils.version import LooseVersion +from ansible import __version__ as __ansible_version__ CONFIG_TYPES = { 'ini': 'return_config_overrides_ini', @@ -629,14 +631,24 @@ class ActionModule(ActionBase): self._connection._shell.join_path(tmp, 'source'), resultant ) - new_module_args.update( - dict( - src=transferred_data, - dest=_vars['dest'], - original_basename=os.path.basename(source), - follow=True, - ), - ) + if LooseVersion(__ansible_version__) < LooseVersion("2.6"): + new_module_args.update( + dict( + src=transferred_data, + dest=_vars['dest'], + original_basename=os.path.basename(source), + follow=True, + ), + ) + else: + new_module_args.update( + dict( + src=transferred_data, + dest=_vars['dest'], + _original_basename=os.path.basename(source), + follow=True, + ), + ) # Remove data types that are not available to the copy module new_module_args.pop('config_overrides', None)