# ansible check and diff mode not working

**URL:** <https://forum.ansible.com/t/ansible-check-and-diff-mode-not-working/33395>\
**Category:** Ansible Project\
**Created:** [July 14, 2020, 5:46pm UTC](https://forum.ansible.com/t/ansible-check-and-diff-mode-not-working/33395 "2020-07-14T17:46:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shyam\_Sunder1](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@Shyam\_Sunder1](https://forum.ansible.com/u/Shyam_Sunder1)\
**Post date:** [July 14, 2020, 5:46pm UTC](https://forum.ansible.com/t/ansible-check-and-diff-mode-not-working/33395/1 "2020-07-14T17:46:12Z")

</div>

Hi,

I was going thru this post ([https://blog.networktocode.com/post/generating-diff-with-ansible/](https://blog.networktocode.com/post/generating-diff-with-ansible/)) where its mentioned that we can use check and diff mode together. I am trying to use that for gold config audit (audit pre decided config against what is present on device) for Cisco and Extreme devices. Below is my playbook –

`

# task to audit & heal ntp configuration

- name: Set NTP template  
ios\_config:  
src: “{{domain}}\_{{ansible\_network\_os}}\_ntp.cfg”  
match: line  
register: ntp\_result  
`

Below is my template -

`ntp server 10.19.70.1`

**Ansible highlighting that it is going to change the config. Below is what result I am getting. Surprisingly I am not getting any config diff.**

`"ntp_result": { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": true, "commands": ["configure ntp server add x.x.x.x"], "failed": false, "updates": ["configure ntp server add x.x.x.x"], "warnings": ["unable to perform diff against running-config due to check mode"] }`

**Why I am not getting config diff? Any idea what is wrong?**

---

<div class="post-metadata">

**Author:** ![Srinivas\_Naram](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@Srinivas\_Naram](https://forum.ansible.com/u/Srinivas_Naram)\
**Post date:** [July 15, 2020, 7:24am UTC](https://forum.ansible.com/t/ansible-check-and-diff-mode-not-working/33395/2 "2020-07-15T07:24:53Z")

</div>

Hello Shyam

It is how the output is displayed. In your output updates are showing the difference in running config and your cfg file.

“updates”: [  
“configure ntp server add x.x.x.x”  
],

I don’t see any issue with the output. Did you try changing the ntp setting on the device yourself and check out the difference in output ?

---

<div class="post-metadata">

**Author:** ![Shyam\_Sunder1](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@Shyam\_Sunder1](https://forum.ansible.com/u/Shyam_Sunder1)\
**Post date:** [July 15, 2020, 8:08am UTC](https://forum.ansible.com/t/ansible-check-and-diff-mode-not-working/33395/3 "2020-07-15T08:08:03Z")

</div>

Thanks for reply. Yes below is my intended config -

`ntp server 10.19.70.1`

But on device we have different ntp server configured -

`ntp server 10.19.60.9`

**Here in updates section, ansible guiding me that its going to push this NTP config. But what config already exits is not mentioned or pushing against what config is not shown. Do anyone has any working example of this?**

**Why there is a warning shown that it can’t diff when check mode is enabled? In documentation ([https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_checkmode.html](https://docs.ansible.com/ansible/latest/user_guide/playbooks_checkmode.html)) its mentioned that we can use these together.**

-Shyam

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [July 15, 2020, 8:30am UTC](https://forum.ansible.com/t/ansible-check-and-diff-mode-not-working/33395/4 "2020-07-15T08:30:06Z")

</div>

> Thanks for reply. Yes below is my intended config -  
> \>  
> ntp server 10.19.70.1  
> \>
> 
> But on device we have different ntp server configured -  
> \>  
> ntp server 10.19.60.9  
> \>  
> \*  
> Here in updates section, ansible guiding me that its going to push this NTP config. But what config already exits is not  
> mentioned or pushing against what config is not shown. Do anyone has any working example of this?
> 
> Why there is a warning shown that it can't diff when check mode is enabled? In documentation  
> ([https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_checkmode.html](https://docs.ansible.com/ansible/latest/user_guide/playbooks_checkmode.html)) its mentioned that we can use these together.\*

It looks like a shortcoming of this module. Usually --check and --diff works together without hassle.

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Shyam\_Sunder1](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@Shyam\_Sunder1](https://forum.ansible.com/u/Shyam_Sunder1)\
**Post date:** [July 15, 2020, 8:40am UTC](https://forum.ansible.com/t/ansible-check-and-diff-mode-not-working/33395/5 "2020-07-15T08:40:46Z")

</div>

I am sure if that is true. Because I could reproduce this for other network modules also like (exos\_config, eos\_config). In the first tutorial ([https://blog.networktocode.com/post/generating-diff-with-ansible/](https://blog.networktocode.com/post/generating-diff-with-ansible/)) I posted, its mentioned that these module support diff & check mode. But no sample exits online. Somehow its not working for me. I thought someone could guide with this.

-Shyam
