I have thousands of servers that, by default, for security and space do not create a $HOME when you ssh in.

This seems to be posing a problem for Ansible as it keeps trying to chdir to home that does not exist. Can I get Ansible to use another directory in the ansible.cfg or just stop this behaviour completely?



inventory      = /home/welshch/.ansible/hosts
remote_tmp     = /tmp
local_tmp      = ~/.ansible/tmp
interpreter_python = auto_silent
roles_path    = /home/eekfonky/.ansible/roles
host_key_checking = False

Here is the error with the server name changed for security reasons;

☁  .ansible  ansible-playbook get_fleet_info.yml -vvvv
fatal: [ldap-corp-search-server.com]: FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    "changed": false,
    "module_stderr": "OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017\r\ndebug1: Reading configuration data /home/eekfonky/.ssh/config\r\ndebug1: /home/eekfonky/.ssh/config line 2: Applying options for *\r\ndebug3: /home/eekfonky/.ssh/config line 9: Including file /home/eekfonky/.ssh/bastions-config depth 0\r\ndebug1: Reading configuration data /home/eekfonky/.ssh/bastions-config\r\ndebug1: /home/eekfonky/.ssh/bastions-config line 10: Applying options for *.corp.amazon.com\r\ndebug1: /home/ekfonky/.ssh/bastions-config line 35: Applying options for *.pdx*.server.com\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 58: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 27395\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 1\r\nShared connection to ldap-corp-search-server.com closed.\r\n",
    "module_stdout": "Could not chdir to home directory /home/eekfonky: No such file or directory\r\n",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
  • 1
    can you post an actual error message from Ansible? It's unclear from your question as stated where the problem may lie. Commented Mar 23, 2022 at 18:12

1 Answer 1


I assume that you are referring to verbose output similar like

TASK [Task] *****************************************************************************************************************
task path: taskFile:<lineNumber>
<IP> ESTABLISH ... CONNECTION FOR USER: {{ ansible_user }}
<IP> EXEC /bin/sh -c 'echo ~{{ ansible_user }} && sleep 0'
<IP> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/{{ ansible_user }}/.ansible/tmp `"&& mkdir "` echo /home/{{ ansible_user }}/.ansible/tmp/ansible-tmp-1234567890 `" && echo ansible-tmp-1234567890="` echo /home/{{ ansible_user }}/.ansible/tmp/ansible-tmp-1234567890 `" ) && sleep 0'
Using module file /usr/lib/python2.7/site-packages/ansible/modules/files/find.py

Can I get Ansible to use another directory ...

According an older documentation (v2.3), it is possible to change that value. The configuration parameter local_tmp might still be available in latest version.

When Ansible gets ready to send a module to a remote machine ... The default location is a subdirectory of the user’s home directory. If you’d like to change that, you can do so by altering this setting


Further Q&A

it should be the variable remote_tmp.

  • samer error shows with /tmp changed. It appaers to be due to no $HOME, which is expected as there isn't one. I need to be able to state the directory on SSH connection in Ansible
    – eekfonky
    Commented Mar 25, 2022 at 10:26
  • @eekfonky, can you update your original question with your full ansible.cfg, as well the error message from verbose -vvvv output after re-running your playbook with gather_facts: false?
    – U880D
    Commented Mar 25, 2022 at 10:32
  • posted failure and .cfg
    – eekfonky
    Commented Mar 28, 2022 at 7:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.