Cannot generate diff with shell module

I am trying to use the shell module to generate a diff between two remote files, but it is erring out without giving me a warning or error:

`

  • name: create diff of old settings file and new settings file
    shell: diff /home/deploy/{{ application_name }}/shared/config/settings.yml /home/deploy/{{ application_name }}/shared/config/settings.yml.ansible_old_version >> /home/deploy/{{ application_name }}/shared/config/settings.yml_diffs_1
    when: settings_file.changed

`

It executes totally fine when run directly in a shell on the remote machine…

Here is the verbose error output, which doesn’t seem to give much of use:

Thanks for any help or workaround! I’ve spent too much time on this…

`

fatal: [staging]: FAILED! => {“changed”: true, “cmd”: “diff /home/deploy/app_name/shared/config/settings.yml /home/deploy/app_name/shared/config/settings.yml.ansible_old_version > /home/deploy/coverhound/shared/config/settings.yml_diffs/settings.yml_2016-11-30_14:45:54”, “delta”: “0:00:00.002778”, “end”: “2016-11-30 14:45:57.198400”, “failed”: true, “invocation”: {“module_args”: {“_raw_params”: “diff /home/deploy/coverhound/shared/config/settings.yml /home/deploy/app_name/shared/config/settings.yml.ansible_old_version > /home/deploy/app_name/shared/config/settings.yml_diffs/settings.yml_2016-11-30_14:45:54”, “_uses_shell”: true, “chdir”: null, “creates”: null, “executable”: “/bin/bash”, “removes”: null, “warn”: true}, “module_name”: “command”}, “rc”: 1, “start”: “2016-11-30 14:45:57.195622”, “stderr”: “”, “stdout”: “”, “stdout_lines”: , “warnings”: }

`

Hello -

I solved a similar problem before by following a suggestion on the shell module page.

To sanitize any variables passed to the shell module, you should use “{{ var | quote }}” instead of just “{{ var }}” to make sure they don’t include evil things like semicolons.

Based on the _raw_params in the verbose output, your variables do contain hyphens, colons, etc. Ansible might be interpreting these as something you don’t want.

Maybe. Give it a shot. :slight_smile:

I stripped it down to the most basic diff command and made your suggested change, but nothing! I am using ansible version 2.1.2.0 for what it’s worth to anyone. It actually generated the diff on the remote, so I am just going to turn on ignore_errors for now :confused: Thanks for the help.