# delete a remote file

**URL:** <https://forum.ansible.com/t/delete-a-remote-file/18432>\
**Category:** Ansible Project\
**Created:** [June 8, 2015, 4:11pm UTC](https://forum.ansible.com/t/delete-a-remote-file/18432 "2015-06-08T16:11:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![richard\_kappler](https://avatars.discourse-cdn.com/v4/letter/r/977dab/32.png) [@richard\_kappler](https://forum.ansible.com/u/richard_kappler)\
**Post date:** [June 8, 2015, 4:11pm UTC](https://forum.ansible.com/t/delete-a-remote-file/18432/1 "2015-06-08T16:11:57Z")

</div>

What is the proper way to delete a remote file. Example: If I’ve used Ansible to copy a file to a remote server, how do I delete it from ansible?

I’ve looked in the docs, googled it, tried using the shell command with rm, also with src= removes=True; I’ve tried the same in command, I’ve even tried file: path=~/ state=absent

I’m getting no errors, but when I go check the remote server, the file is still there.

regards, Richard

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 8, 2015, 4:58pm UTC](https://forum.ansible.com/t/delete-a-remote-file/18432/2 "2015-06-08T16:58:57Z")

</div>

Your file command is the correct one to use, just note that  
path=~/\<filename\> will depend on the remote user. try using the full  
path when in doubt.

---

<div class="post-metadata">

**Author:** ![richard\_kappler](https://avatars.discourse-cdn.com/v4/letter/r/977dab/32.png) [@richard\_kappler](https://forum.ansible.com/u/richard_kappler)\
**Post date:** [June 9, 2015, 2:56pm UTC](https://forum.ansible.com/t/delete-a-remote-file/18432/3 "2015-06-09T14:56:39Z")

</div>

Brilliant, thanks!
