# Ansible problem when i use --check

**URL:** <https://forum.ansible.com/t/ansible-problem-when-i-use-check/31208>\
**Category:** Ansible Project\
**Created:** [September 5, 2019, 2:48pm UTC](https://forum.ansible.com/t/ansible-problem-when-i-use-check/31208 "2019-09-05T14:48:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karther](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@Karther](https://forum.ansible.com/u/Karther)\
**Post date:** [September 5, 2019, 2:48pm UTC](https://forum.ansible.com/t/ansible-problem-when-i-use-check/31208/1 "2019-09-05T14:48:50Z")

</div>

Hey !

I have problem when i use this command **ansible-playbook playbook.yml --check**

All works normaly without **–check** but when there is one task who create repertory, the second task is mistake.

Exemple :

- name: “Create repertory”  
file:  
path: /var/apps/my\_repertory  
state: directory

- name: “Create file in my repertory”  
file:  
src: /home/wildfly/my\_file  
dest: /var/apps/my\_repertory/my\_file

This tasks works perfectly without **–check** but when i use --check, the second task is mistake because ansible not really create my repertory …

Someone have any idea please community ansible ??!! =)

Thanks very much !! ^^

Regards,

Karther

---

<div class="post-metadata">

**Author:** ![Karther](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@Karther](https://forum.ansible.com/u/Karther)\
**Post date:** [September 5, 2019, 3:26pm UTC](https://forum.ansible.com/t/ansible-problem-when-i-use-check/31208/2 "2019-09-05T15:26:18Z")

</div>

Someone can help me please community ansible ??!!

Thanks very much !! 🙂

Regards,

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [September 5, 2019, 11:58pm UTC](https://forum.ansible.com/t/ansible-problem-when-i-use-check/31208/3 "2019-09-05T23:58:47Z")

</div>

Yes, that is how it's supposed to work. The second task is dependent  
on the first one, in this case only the first task can be used with  
--check.  
Getting a playbook to work properly with --check can be a tricky task,  
you'll have to look at the logic in detail.  
[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_checkmode.html](https://docs.ansible.com/ansible/latest/user_guide/playbooks_checkmode.html)

---

<div class="post-metadata">

**Author:** ![Stefan\_Schmid](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@Stefan\_Schmid](https://forum.ansible.com/u/Stefan_Schmid)\
**Post date:** [September 6, 2019, 3:05pm UTC](https://forum.ansible.com/t/ansible-problem-when-i-use-check/31208/4 "2019-09-06T15:05:25Z")

</div>

Add the following to the second task at the end:

when: not ansible\_check\_mode

---

<div class="post-metadata">

**Author:** ![Karther](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@Karther](https://forum.ansible.com/u/Karther)\
**Post date:** [September 10, 2019, 8:36am UTC](https://forum.ansible.com/t/ansible-problem-when-i-use-check/31208/5 "2019-09-10T08:36:41Z")

</div>

Hey !! 🙂

Thanks very much for your answer community Ansible !! ^^

If i use this condiiton **when: not ansible\_check\_mode** i don’t can verify if my task works … 😕

It’s very pity that aspect check mode is not full and strong… ☹

Thanks,

Regards,

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [September 10, 2019, 9:01am UTC](https://forum.ansible.com/t/ansible-problem-when-i-use-check/31208/6 "2019-09-10T09:01:23Z")

</div>

Hi,

> [...]  
> If i use this condiiton \*when: not ansible\_check\_mode\* i don't can verify  
> if my task works ... 😕  
> It's very pity that aspect check mode is not full and strong... ☹

The option "--check" can be only as "full and strong" as is the support of  
the modules. If you think you've found an aspect that is "very pity" just  
open an issue with the module (ideally submit a pull-request).

Quoting from man ansible-playbook:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-C, --check  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;don't make any changes; instead, try to predict some of the changes  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;that may occur

Cheers,

&nbsp;&nbsp;-vlado
