Fix ordering for --diff mode setup

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:

https://github.com/ceph/ceph-ansible/issues/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
This commit is contained in:
Andy McCrae 2018-06-18 11:35:06 +01:00
parent a5c9d97e18
commit 4d93182786
2 changed files with 5 additions and 2 deletions

View File

@ -672,6 +672,9 @@ class ActionModule(ActionBase):
# 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',
@ -680,8 +683,7 @@ class ActionModule(ActionBase):
)
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

View File

@ -34,6 +34,7 @@ setenv =
ANSIBLE_LOOKUP_PLUGINS={toxinidir}/lookup
ANSIBLE_STRATEGY_PLUGINS={toxinidir}/strategy
ANSIBLE_LIBRARY={toxinidir}/library
ANSIBLE_PARAMETERS=--diff
[testenv:docs]