How to delete local directory with ansible

Neil picture Neil · Feb 23, 2017 · Viewed 14.8k times · Source

I have to make delete some directory and create them on local before copy to the remote. Is there anyway to delete and create locally?

Currently I'm using 'command'

command: rm -r directory

But warning shows as

Consider using file module with state=absent rather than running rm

Is there any options we can use for local folder changes?

Answer

flxPeters picture flxPeters · Feb 23, 2017

You can use diffrent delegation methods or use the local_action:

- local_action: file path=directory state=absent