Depending on the overall scenario you can use the fail module. Otherwise,
you’ll need to put conditionals on all other tasks in the playbook to just
skip when the condition is not met.

On Fri, Jan 24, 2020 at 14:01 Anand Solomon <anand.v.solo...@gmail.com>
wrote:

> Hi,
> I basically wanted to skip the remaining of the playbook if a file exists
>
>
>     - name: Check if the file exists
>       stat:
>         path: /home/ansible/dbname/sql/file.sql
>       register: optional_file
>
>     - debug:
>         msg: "File Exists"
>       when: optional_file.stat.exists == True
>
> Also, Is there a way I read the same file, and based on a string I stop
> the remaining playbook?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-devel+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-devel/4ca6e132-6757-4f0a-9246-cf2795c41240%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-devel/4ca6e132-6757-4f0a-9246-cf2795c41240%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/CA%2Bs1_jS7DRt9U_txz3%2BnsX0Rtmq_3pPko%3DO1mWTKofjeUksm-w%40mail.gmail.com.

Reply via email to