Handling "file not found" for the slurp module

254 views
Skip to first unread message

Shabir Abdul Samdh

unread,
Sep 26, 2022, 11:10:31 PM9/26/22
to ansible...@googlegroups.com
Hello All,

I am trying to read a file from a remote host and do some checks on its content using the slurp module. However I want these checks to run only if the file exists. If the file is not found I want to skip some of the following tasks.

However, it seems like the slurp module fails when the file I am looking for is not found. Is there a way to handle the case of a file not being there gracefully when using slurp?

Thank you very much
Best regards
---
Shabir

Dick Visser

unread,
Sep 26, 2022, 11:45:48 PM9/26/22
to ansible...@googlegroups.com
Add a stat task first and use the result to conditionally run the slurp task

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAGK3r_gHYeG4_M1pqzNEX8pp182oUQaQgHYpxh7mtd_iuaekNw%40mail.gmail.com.
--
Sent from Gmail Mobile

Shabir Abdul Samdh

unread,
Sep 27, 2022, 9:56:25 AM9/27/22
to Ansible Project
Yup! That works. Thank you.
Reply all
Reply to author
Forward
0 new messages