# Force ansible remote directory to /tmp

**URL:** <https://forum.ansible.com/t/force-ansible-remote-directory-to-tmp/30982>\
**Category:** Ansible Project\
**Created:** [August 7, 2019, 11:32pm UTC](https://forum.ansible.com/t/force-ansible-remote-directory-to-tmp/30982 "2019-08-07T23:32:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rich\_Rauenzahn](https://avatars.discourse-cdn.com/v4/letter/r/c89c15/32.png) [@Rich\_Rauenzahn](https://forum.ansible.com/u/Rich_Rauenzahn)\
**Post date:** [August 7, 2019, 11:32pm UTC](https://forum.ansible.com/t/force-ansible-remote-directory-to-tmp/30982/1 "2019-08-07T23:32:08Z")

</div>

My ansible runs really slowly, I’ve looked at various things, and one thing I haven’t eliminated yet is that ansible runs in my NFS directory as it ssh’es around. I’ve run ansible before and its performance is fine usually – but the biggest difference in this setup is slow NFS and extra latency to the remote systems.

I’m in the process of trying the following and I think it is _not_ working. I think sudo grabs the /tmp and then it runs /bin/sh as me.

[defaults]  
executable=cd /tmp \&\& /bin/sh

Is there a better way?

(I’ve attached strace to the remote sshd while running – the biggest hit visually watching the system calls scroll by is python loading for every ansible statement. So I want to move $CWD to /tmp to minimize python reading the $CWD as it searches its paths – which is fairly slow NFS.)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [August 8, 2019, 7:53pm UTC](https://forum.ansible.com/t/force-ansible-remote-directory-to-tmp/30982/2 "2019-08-08T19:53:13Z")

</div>

> From the docs:

[https://docs.ansible.com/ansible/latest/plugins/shell/sh.html?highlight=ansible\_remote\_tmp](https://docs.ansible.com/ansible/latest/plugins/shell/sh.html?highlight=ansible_remote_tmp)

you can add this to your ansible.cfg  
[defaults]  
remote\_tmp = /tmp

or you can use and env var or even set it per group/host via  
ansible\_remote\_tmp var

---

<div class="post-metadata">

**Author:** ![Rich\_Rauenzahn](https://avatars.discourse-cdn.com/v4/letter/r/c89c15/32.png) [@Rich\_Rauenzahn](https://forum.ansible.com/u/Rich_Rauenzahn)\
**Post date:** [August 9, 2019, 4:05am UTC](https://forum.ansible.com/t/force-ansible-remote-directory-to-tmp/30982/3 "2019-08-09T04:05:17Z")

</div>

I already have remotr\_tmp set. That doesn't change the working / current directory away from the remote ssh user's home directory as far as I can tell by watching strace.

---

<div class="post-metadata">

**Author:** ![Rich\_Rauenzahn](https://avatars.discourse-cdn.com/v4/letter/r/c89c15/32.png) [@Rich\_Rauenzahn](https://forum.ansible.com/u/Rich_Rauenzahn)\
**Post date:** [August 9, 2019, 4:50pm UTC](https://forum.ansible.com/t/force-ansible-remote-directory-to-tmp/30982/4 "2019-08-09T16:50:20Z")

</div>

Nevermind - I just discovered mitogen! WOW – what an improvement!

Rich
