# Remove and create directory in a single task is failing

**URL:** <https://forum.ansible.com/t/remove-and-create-directory-in-a-single-task-is-failing/29316>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [December 21, 2018, 12:16pm UTC](https://forum.ansible.com/t/remove-and-create-directory-in-a-single-task-is-failing/29316 "2018-12-21T12:16:57Z")\
**Posts on this page:** 1\
**Page:** 1

<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:** [December 21, 2018, 12:16pm UTC](https://forum.ansible.com/t/remove-and-create-directory-in-a-single-task-is-failing/29316/1 "2018-12-21T12:16:57Z")

</div>

This is the same question as you asked in an earlier thread - to which  
you got two answers.  
Without any feedback on how that worked out for you (did you actually  
try them? did they work?), you are now trying almost the same solution  
again, which is failing in a similar way.  
Instead of shoehorning what you think should work and ignoring the  
provided answers, can you please read them and try them out?

In any case, removing and recreating directories in a single task  
sounds like a bad thing to do to begin with.

To give some hint, in order of elegance, the options are:

1. find and register all files/dirs, and then delete those  
2. use a shell task to "rm -rf" the contents

Dick
