Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples on how to remove files and directories #57766

Merged
merged 2 commits into from Jun 18, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -196,6 +196,16 @@
owner: foo
group: foo
- name: Remove file (delete file)
file:
path: /etc/foo
This conversation was marked as resolved by szabgab

This comment has been minimized.

Copy link
@acozine

acozine Jun 17, 2019

Contributor

I would give the example for removing a file some kind of extension, so it's clear that it's targeting a file rather than a directory.

Suggested change
path: /etc/foo
path: /etc/foo.txt
state: absent
- name: Recursively remove directory
This conversation was marked as resolved by samdoran

This comment has been minimized.

Copy link
@samdoran

samdoran Jun 13, 2019

Member

I don't feel this is correct. This looks like the same code twice. This may need recurse: yes in order to delete directories.

This comment has been minimized.

Copy link
@s-hertel

s-hertel Jun 13, 2019

Contributor

I was mistaken, it looks like recurse can only be used with state 'directory'.

Since these are the same example though, it could probably just be combined.

But @sivel has pointed out #52656, which would make recurse apply here.

This comment has been minimized.

Copy link
@szabgab

szabgab Jun 18, 2019

Author Contributor

I tried these and they worked as I pasted them here. Is it a bug in the file module? Should they not work?

This comment has been minimized.

Copy link
@samdoran

samdoran Jun 18, 2019

Member

I just had some time to look at this more closely and this is working correctly. As @s-hertel said, recure: yes is only valid for state: directory but isn't needed when removing directories.

file:
path: /etc/foo
state: absent
'''
RETURN = r'''
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.