# Set ANSIBLE\_KEEP\_REMOTE\_FILES=1 in module

**URL:** <https://forum.ansible.com/t/set-ansible-keep-remote-files-1-in-module/33538>\
**Category:** Ansible Developer\
**Created:** [August 1, 2020, 9:09am UTC](https://forum.ansible.com/t/set-ansible-keep-remote-files-1-in-module/33538 "2020-08-01T09:09:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amin\_Vakil](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@Amin\_Vakil](https://forum.ansible.com/u/Amin_Vakil)\
**Post date:** [August 1, 2020, 9:09am UTC](https://forum.ansible.com/t/set-ansible-keep-remote-files-1-in-module/33538/1 "2020-08-01T09:09:12Z")

</div>

I’m trying to contribute a new action to ansible-collections/community.general ([https://github.com/ansible-collections/community.general/pull/700](https://github.com/ansible-collections/community.general/pull/700)), it shuts down the remote server.

As ansible tries to remove temp files after executing the module and the server is not running, it always gives an error (cannot connect to server).

It can be verified that  
`  
export ANSIBLE\_KEEP\_REMOTE\_FILES=1

`  
fixes the issue and the module runs correctly.

But of course user cannot always set this in his configurations.

Is there a way to tell the module not to keep remote files always?

---

<div class="post-metadata">

**Author:** ![Amin\_Vakil](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@Amin\_Vakil](https://forum.ansible.com/u/Amin_Vakil)\
**Post date:** [August 5, 2020, 3:18pm UTC](https://forum.ansible.com/t/set-ansible-keep-remote-files-1-in-module/33538/2 "2020-08-05T15:18:10Z")

</div>

Issue got resolved by calling self.cleanup function exactly before the shutdown execution, more information in [https://github.com/ansible-collections/community.general/pull/700/commits/e5a8eeb1bf86d58eb1619919a8319b1cb4e4fc91](https://github.com/ansible-collections/community.general/pull/700/commits/e5a8eeb1bf86d58eb1619919a8319b1cb4e4fc91) and the commits afterwards.
