You could register the output of tempfile in a variable and use the block
rescue feature.
Something like:
connection: local
tasks:
- block:
- tempfile:
state: directory
register: tempfile_out
- command: /bin/false
rescue:
- debug: msg="Yikes, something broke, cleaning up tmp dir {{
tempfile_out.path }}"
- file:
name: "{{ tempfile_out.path }}"
state: absent
El viernes, 31 de marzo de 2017, 11:29:35 (UTC+2), Cev Ing escribió:
>
> In Bash I use mktemp together with trap to always remove the temp dir.
>
> When I use the tempfile module, how do I remove the tempfile, in case of
> an error, which terminates the playbook run?
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/4486c8a1-decb-45a0-a4c1-6e62ce7b898b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.