# Cannot generate diff with shell module

**URL:** <https://forum.ansible.com/t/cannot-generate-diff-with-shell-module/23143>\
**Category:** Ansible Project\
**Created:** [November 30, 2016, 11:08pm UTC](https://forum.ansible.com/t/cannot-generate-diff-with-shell-module/23143 "2016-11-30T23:08:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Colin\_Byrne](https://avatars.discourse-cdn.com/v4/letter/c/ecd19e/32.png) [@Colin\_Byrne](https://forum.ansible.com/u/Colin_Byrne)\
**Post date:** [November 30, 2016, 11:08pm UTC](https://forum.ansible.com/t/cannot-generate-diff-with-shell-module/23143/1 "2016-11-30T23:08:35Z")

</div>

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”: }

`

---

<div class="post-metadata">

**Author:** ![burns498](https://avatars.discourse-cdn.com/v4/letter/b/b487fb/32.png) [@burns498](https://forum.ansible.com/u/burns498)\
**Post date:** [November 30, 2016, 11:23pm UTC](https://forum.ansible.com/t/cannot-generate-diff-with-shell-module/23143/2 "2016-11-30T23:23:52Z")

</div>

Hello -

I solved a similar problem before by following a suggestion on the [shell module](http://docs.ansible.com/ansible/shell_module.html) 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. 🙂

---

<div class="post-metadata">

**Author:** ![Colin\_Byrne](https://avatars.discourse-cdn.com/v4/letter/c/ecd19e/32.png) [@Colin\_Byrne](https://forum.ansible.com/u/Colin_Byrne)\
**Post date:** [November 30, 2016, 11:45pm UTC](https://forum.ansible.com/t/cannot-generate-diff-with-shell-module/23143/3 "2016-11-30T23:45:56Z")

</div>

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 😕 Thanks for the help.
