Change Ansible Temporary Directory

While running ansible playbooks, you will find it impossible to use an ssh account that doesn't have a home directory, or has one which isn't writable. You'll see a message similar to the following:

fatal: [user] => Authentication or permission failure.  In some cases, you 
may have been able to authenticate and did not have permissions on the remote 
directory. Consider changing the remote temp path in ansible.cfg to a path 
rooted in "/tmp". Failed command was: mkdir -p 
$HOME/.ansible/tmp/ansible-tmp-1401973086.25-185293296215162 && echo 
$HOME/.ansible/tmp/ansible-tmp-1401973086.25-185293296215162, exited with 
result 1

The simple solution is to use a path in /tmp which all users will be able to write to. They were thoughtful enough to include this workaround in the error message, but not sure why they don't use this as a default.

In your ansible.cfg change

remote_tmp     = $HOME/.ansible/tmp


remote_tmp     = /tmp/.ansible-${USER}/tmp

View Comments