file module: absent recurse=yes and Directory not empty

4,396 views
Skip to first unread message

Maxim Odinintsev

unread,
Apr 4, 2014, 9:48:33 AM4/4/14
to ansible...@googlegroups.com
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

Michael DeHaan

unread,
Apr 4, 2014, 11:24:00 AM4/4/14
to ansible...@googlegroups.com
Sounds like a good feature request or pull request addition -- can you file a ticket on github.com/ansible/ansible ?




--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/468b6757-2798-4003-ab2a-d9e5e85b6cd4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matt Martz

unread,
Apr 4, 2014, 12:29:34 PM4/4/14
to Maxim Odinintsev, ansible...@googlegroups.com
I will mention that we use 'file' to recursively delete a directory, but it does require 'force=yes'
-- 
Matt Martz
ma...@sivel.net

Michael DeHaan

unread,
Apr 4, 2014, 2:11:55 PM4/4/14
to ansible...@googlegroups.com, Maxim Odinintsev
Perhaps the force is causing extra checking?

If so, maybe it can be removed.


santosh verma

unread,
Nov 28, 2016, 7:05:36 PM11/28/16
to Ansible Project, gwyn...@gmail.com
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



Diego Villacis

unread,
Mar 9, 2017, 3:01:10 AM3/9/17
to Ansible Project
Getting the same error, does anyone know if there is any update on this?
Reply all
Reply to author
Forward
0 new messages