Ansible: How to delete files and folders inside a directory?

Question:

The below code only deletes the first file it gets inside the web dir. I want to remove all the files and folders inside the web directory and retain the web directory. How can I do that?

Note: I’ve tried rm -rf using command and shell, but they don’t work. Perhaps I am using them wrongly.

Any help in the right direction will be appreciated.

I am using ansible 2.1.0.0

Answer:


Note: this will delete the directory too.

Leave a Reply