Skip to content

Commit

Permalink
Fix config_template to work with Ansible 2.6
Browse files Browse the repository at this point in the history
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
  • Loading branch information
andymcc committed Jul 4, 2018
1 parent df1875a commit fcf669b
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions action/config_template.py
Expand Up @@ -39,6 +39,8 @@
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__

__metaclass__ = type

Expand Down Expand Up @@ -654,14 +656,24 @@ def run(self, tmp=None, task_vars=None):
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)
Expand Down

0 comments on commit fcf669b

Please sign in to comment.