# ansible-playbook --check

**URL:** <https://forum.ansible.com/t/ansible-playbook-check/12593>\
**Category:** Ansible Project\
**Created:** [March 27, 2013, 12:39pm UTC](https://forum.ansible.com/t/ansible-playbook-check/12593 "2013-03-27T12:39:44Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oleg\_A\_Mamontov](https://avatars.discourse-cdn.com/v4/letter/o/7ba0ec/32.png) [@Oleg\_A\_Mamontov](https://forum.ansible.com/u/Oleg_A_Mamontov)\
**Post date:** [March 27, 2013, 12:39pm UTC](https://forum.ansible.com/t/ansible-playbook-check/12593/1 "2013-03-27T12:39:44Z")

</div>

Hello!

In one of playbooks i have template action with: 'owner=pgsql  
group=pgsql mode=0400'.  
Playbook has 'sudo: yes' declared and work properly.  
But ansible-playbook called with '--check --diff' can't diff file, i  
suupose this scenario executes without sudo calling, am i right?

I also tried to force apply command line sudo switch:  
'ansible-playbook postgresql.yml --check --diff --sudo'  
It does not work well ☹

Is it right behaviour or bug?

Thank you an advance!

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [March 28, 2013, 11:06pm UTC](https://forum.ansible.com/t/ansible-playbook-check/12593/2 "2013-03-28T23:06:44Z")

</div>

Can you explain what "cannot diff file" means?

Any particular output you are seeing?

---

<div class="post-metadata">

**Author:** ![Oleg\_A\_Mamontov](https://avatars.discourse-cdn.com/v4/letter/o/7ba0ec/32.png) [@Oleg\_A\_Mamontov](https://forum.ansible.com/u/Oleg_A_Mamontov)\
**Post date:** [March 29, 2013, 5:07am UTC](https://forum.ansible.com/t/ansible-playbook-check/12593/3 "2013-03-29T05:07:34Z")

</div>

> Can you explain what "cannot diff file" means?
> 
> Any particular output you are seeing?

Ok, i can demostrate real example.

> From postgresql playbook:

- hosts: postgresql  
&nbsp;&nbsp;sudo: yes  
&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;- name: create postgresql data directory  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# directory restrictive permissions required!  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;file: path=${postgresql.datadir} state=directory owner=pgsql group=pgsql mode=0700  
&nbsp;&nbsp;&nbsp;&nbsp;- name: configure postgresql  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;template: src=templates/postgresql/postgresql.conf dest=${postgresql.datadir}/ owner=pgsql group=pgsql mode=0444

Now play:

(ansible)[lonerr@neon ~/src]% ansible-playbook postgresql.yml  
PLAY [postgresql] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [db01]  
TASK: [create postgresql data directory] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [db01]  
TASK: [configure postgresql] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [db01] =\> (item=./templates/postgresql/postgresql.conf)  
PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
db01 : ok=3 changed=0 unreachable=0 failed=0

As you can see, file is in actual state, now run with '--check --diff':

(ansible)[lonerr@neon ~/src]% ansible-playbook postgresql.yml --check --diff  
PLAY [postgresql] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [db01]  
TASK: [create postgresql data directory] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [db01]  
TASK: [configure postgresql] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [db01] =\> (item=./templates/postgresql/postgresql.conf)  
PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
db01 : ok=3 changed=1 unreachable=0 failed=0

Do you feel the difference?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [March 29, 2013, 8:20pm UTC](https://forum.ansible.com/t/ansible-playbook-check/12593/4 "2013-03-29T20:20:06Z")

</div>

This is Ansible 1.1?

Output of ansible --version?

Maybe the file attributes required a change by the content was already correct?

---

<div class="post-metadata">

**Author:** ![Oleg\_A\_Mamontov](https://avatars.discourse-cdn.com/v4/letter/o/7ba0ec/32.png) [@Oleg\_A\_Mamontov](https://forum.ansible.com/u/Oleg_A_Mamontov)\
**Post date:** [March 30, 2013, 7:47pm UTC](https://forum.ansible.com/t/ansible-playbook-check/12593/5 "2013-03-30T19:47:19Z")

</div>

> This is Ansible 1.1?
> 
> Output of ansible --version?

Yes:  
(ansible)[lonerr@neon ~/src/Leitung]% ansible --version  
ansible 1.1

---

<div class="post-metadata">

**Author:** ![Marco\_Vito\_Moscarito](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@Marco\_Vito\_Moscarito](https://forum.ansible.com/u/Marco_Vito_Moscarito)\
**Post date:** [March 31, 2013, 4:43pm UTC](https://forum.ansible.com/t/ansible-playbook-check/12593/6 "2013-03-31T16:43:03Z")

</div>

> - hosts: postgresql  
> &nbsp;&nbsp;sudo: yes  
> &nbsp;&nbsp;tasks:  
> &nbsp;&nbsp;&nbsp;&nbsp;- name: create postgresql data directory  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# directory restrictive permissions required!  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;file: path=${postgresql.datadir} state=directory owner=pgsql group=pgsql mode=0700  
> &nbsp;&nbsp;&nbsp;&nbsp;- name: configure postgresql  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;template: src=templates/postgresql/postgresql.conf dest=${postgresql.datadir}/ owner=pgsql group=pgsql mode=0444

Template destination ned to be a file, try this:

> template: src=templates/postgresql/postgresql.conf dest=${postgresql.datadir}/postgresql.conf owner=pgsql group=pgsql mode=0444

Bye  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Marco

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [March 31, 2013, 5:37pm UTC](https://forum.ansible.com/t/ansible-playbook-check/12593/7 "2013-03-31T17:37:39Z")

</div>

​That's actually not true any more, in the very latest devel.​

---

<div class="post-metadata">

**Author:** ![Oleg\_A\_Mamontov](https://avatars.discourse-cdn.com/v4/letter/o/7ba0ec/32.png) [@Oleg\_A\_Mamontov](https://forum.ansible.com/u/Oleg_A_Mamontov)\
**Post date:** [March 31, 2013, 8:30pm UTC](https://forum.ansible.com/t/ansible-playbook-check/12593/8 "2013-03-31T20:30:33Z")

</div>

> \> - hosts: postgresql  
> \> sudo: yes  
> \> tasks:  
> \> - name: create postgresql data directory  
> \> # directory restrictive permissions required!  
> \> file: path=${postgresql.datadir} state=directory owner=pgsql group=pgsql mode=0700  
> \> - name: configure postgresql  
> \> template: src=templates/postgresql/postgresql.conf dest=${postgresql.datadir}/ owner=pgsql group=pgsql mode=0444
> 
> Template destination ned to be a file, try this:
> 
> \> template: src=templates/postgresql/postgresql.conf dest=${postgresql.datadir}/postgresql.conf owner=pgsql group=pgsql mode=0444

The same result ☹
