0

So, I am trying to recursively delete a directory with all files/folders inside. I tried:

  - name: Cleaning up
    file:
      state: absent
      path: /tmp/myfolder/

But the directory did not get deleted. Is there any force/recursive parameter I can add? What am I missing?

| improve this question | | | | |
  • 2
    I cannot reproduce this at all - were there any error messages? Are you sure you're targetting the correct host? Is the task "ok" or "changed"? – Bruce Becker Dec 1 '19 at 15:13
  • @BruceBecker The task is changed. I did install files from this directory before, so maybe there is still some process in the background that is not completed that prevents deleting the directory? But I did not get any error prompt. – Kyu96 Dec 1 '19 at 15:24
1

You may find the following format to be helpful:

- name: Recursively change ownership of a directory  
file:  
  path: /etc/foo
  state: directory
  recurse: yes
  owner: foo
  group: foo
| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.