Ansible: How to delete files and folders inside a directory?
<p>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?</p>
<pre class="lang-yml prettyprint-override"><code>- name: remove web dir contents
    file: path='/home/mydata/web/{{ item }}' state=absent
    with_fileglob:
      - /home/mydata/web/*
</code></pre>
<p>Note: I've tried <code>rm -rf</code> using command and shell, but they don't work. Perhaps I am using them wrongly.</p>
<p>Any help in the right direction will be appreciated.</p>
<p>I am using ansible 2.1.0.0</p>