Ansible problem when i use --check

28 views
Skip to first unread message

Karther

unread,
Sep 5, 2019, 10:48:50 AM9/5/19
to Ansible Project
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

Karther

unread,
Sep 5, 2019, 11:26:18 AM9/5/19
to Ansible Project
Someone can help me please community ansible ??!! 

Thanks very much !! :)

Regards,

Dick Visser

unread,
Sep 5, 2019, 7:59:12 PM9/5/19
to ansible...@googlegroups.com
On Thu, 5 Sep 2019 at 16:49, Karther <ryadmo...@gmail.com> wrote:
>
> 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 ....

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




--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

Stefan Schmid

unread,
Sep 6, 2019, 11:14:01 AM9/6/19
to Ansible Project

Add the following to the second task at the end:

when: not ansible_check_mode

Karther

unread,
Sep 10, 2019, 4:36:41 AM9/10/19
to Ansible Project
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,

Vladimir Botka

unread,
Sep 10, 2019, 5:01:38 AM9/10/19
to Karther, ansible...@googlegroups.com
Hi,

On Tue, 10 Sep 2019 01:36:41 -0700 (PDT)
Karther <ryadmo...@gmail.com> wrote:
> [...]
> 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:

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

Cheers,

-vlado
Reply all
Reply to author
Forward
0 new messages