Skip to content

Commit

Permalink
Fix ordering for --diff mode setup
Browse files Browse the repository at this point in the history
Due to the ordering of the vars passed to the _get_diff_data mode,
--diff mode would only work with --check activated, otherwise the file
used didn't exist and you would get an error similar to:

ceph/ceph-ansible#2742

This PR allows this to work by configuring the diff data before running
the copy module, so the file exists.

Additionally, we should run with --diff mode enabled by default on tests
for this repository to ensure any functional issues with diff mode are
caught.

Change-Id: I020a181731c3ee87f04933f8c62213ea12cfa3a4
  • Loading branch information
andymcc committed Jun 20, 2018
1 parent a5c9d97 commit 4d93182
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions action/config_template.py
Expand Up @@ -672,6 +672,9 @@ def run(self, tmp=None, task_vars=None):
# Content from config_template is converted to src
new_module_args.pop('content', None)

# Set the diff data before running the copy module
_diff = self._get_diff_data(_vars['dest'], transferred_data, task_vars)

# Run the copy module
rc = self._execute_module(
module_name='copy',
Expand All @@ -680,8 +683,7 @@ def run(self, tmp=None, task_vars=None):
)
if self._play_context.diff:
rc['diff'] = []
rc['diff'].append(self._get_diff_data(_vars['dest'],
transferred_data, task_vars))
rc['diff'].append(_diff)
if self._task.args.get('content'):
os.remove(_vars['source'])
return rc
1 change: 1 addition & 0 deletions tox.ini
Expand Up @@ -34,6 +34,7 @@ setenv =
ANSIBLE_LOOKUP_PLUGINS={toxinidir}/lookup
ANSIBLE_STRATEGY_PLUGINS={toxinidir}/strategy
ANSIBLE_LIBRARY={toxinidir}/library
ANSIBLE_PARAMETERS=--diff


[testenv:docs]
Expand Down

0 comments on commit 4d93182

Please sign in to comment.