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)
This commit is contained in:
parent
f655fcbaab
commit
5c70fb05d8
|
@ -41,6 +41,8 @@ from ansible.module_utils._text import to_bytes, to_text
|
||||||
from ansible import constants as C
|
from ansible import constants as C
|
||||||
from ansible import errors
|
from ansible import errors
|
||||||
from ansible.parsing.yaml.dumper import AnsibleDumper
|
from ansible.parsing.yaml.dumper import AnsibleDumper
|
||||||
|
from distutils.version import LooseVersion
|
||||||
|
from ansible import __version__ as __ansible_version__
|
||||||
|
|
||||||
CONFIG_TYPES = {
|
CONFIG_TYPES = {
|
||||||
'ini': 'return_config_overrides_ini',
|
'ini': 'return_config_overrides_ini',
|
||||||
|
@ -629,14 +631,24 @@ class ActionModule(ActionBase):
|
||||||
self._connection._shell.join_path(tmp, 'source'),
|
self._connection._shell.join_path(tmp, 'source'),
|
||||||
resultant
|
resultant
|
||||||
)
|
)
|
||||||
new_module_args.update(
|
if LooseVersion(__ansible_version__) < LooseVersion("2.6"):
|
||||||
dict(
|
new_module_args.update(
|
||||||
src=transferred_data,
|
dict(
|
||||||
dest=_vars['dest'],
|
src=transferred_data,
|
||||||
original_basename=os.path.basename(source),
|
dest=_vars['dest'],
|
||||||
follow=True,
|
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
|
# Remove data types that are not available to the copy module
|
||||||
new_module_args.pop('config_overrides', None)
|
new_module_args.pop('config_overrides', None)
|
||||||
|
|
Loading…
Reference in New Issue