file module: absent recurse=yes and Directory not empty

Hello,

When I’m run this job, but on some hosts return output:
rmtree failed: [Errno 39] Directory not empty: ‘/home/master/www/static.master/images/posters’

Sure this directories is not empty, and I’m want remove it recursive. But why i can’t do this with file module ?

`

  • name: Cleaner
    hosts: all
    sudo: yes

tasks:

  • name: get cache dirs
    shell: ls -1 /var/lib/nginx/cache/
    register: cache

  • name: Remove cache
    file: name=/var/lib/nginx/cache/{{ item }} state=absent recurse=yes
    with_items: cache.stdout_lines

  • name: get static dirs
    shell: ls -1 /home/master/www/static.master/
    register: static

  • name: Clean static
    file: name=/home/master/www/static.master/{{ item }} state=absent recurse=yes
    with_items: static.stdout_lines

`

Thank you

Sounds like a good feature request or pull request addition – can you file a ticket on github.com/ansible/ansible ?

I will mention that we use ‘file’ to recursively delete a directory, but it does require ‘force=yes’

Perhaps the force is causing extra checking?

If so, maybe it can be removed.

Still same error:
msg: rmtree failed: [Errno 39] Directory not empty

  • name: Removing jenkins folder
    file: path={{ base_dir }}/tomcat7/webapps/jenkins state=absent force=yes

Getting the same error, does anyone know if there is any update on this?