Essentially, what is going on here is that the user account that ansible is running under is present on both the control node, and the target client.

However, on the target client, as part of the server remediation process, one of the steps is to change where the home directory of that account lives from /home/voltron/ to /opt/home/voltron/ (No, the account can't be created using that directory on server creation sadly.)

The problem in doing this with ansible is that it "loses access" to it's working tmp directory in ~/.ansible/tmp on the target client (in this case the server t-rex). This causes the playbook to fail out on any following play with the following error message:

fatal: [t-rex]: UNREACHABLE! => {"changed": false, "msg": "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: ( umask 77 && mkdir -p \"` echo /home/volton/.ansible/tmp/ansible-tmp-1507231978.66-123682989430617 `\" && echo ansible-tmp-1507231978.66-123682989430617=\"` echo /home/volton/.ansible/tmp/ansible-tmp-1507231978.66-123682989430617 `\" ), exited with result 1", "unreachable": true}

Now, all I need to do is somehow tell ansible that it's working directory on the target client has changed locations during the playbook run by having it re-gather facts, but that does not seem to help. (At least the way I am doing it)

I have tried to immediately call the setup module in the play after the one that changes the location of the ansible account's (voltron) working temp directory, and it "seems" to run, but then when the next "import_playbook" statement is read, the failure described above occurs, a failure is given, and the entire thing blows up forcing me to potentially re-run a fairly long playbook. Obviously, this following run does work because ansible's facts now know that it's working directory has changed.

Anyone have any ideas on how I would inform ansible when it's working temp directory location changes? Let me know, thanks!


1 Answer 1


Why not change the tmp directory ansible uses? E.g. in ansible.cfg set something like

remote_tmp = /var/tmp/notfiddledwithduringtheplay

which may then need to be created as part of a bootstrap process, or you could risk using some common tmp directory, or ...

There's also a local_tmp directory in the event you're instead fiddling around with things on the local system.

  • 1
    So you're basically saying I should mess around with the ansible.cfg file to account for this. Could work, but am I able to specify "rollover" working tmp directories to ensure this doesn't happen? I was also hoping something from within a playbook could solve it as well.
    – Viscosity
    Mar 8, 2018 at 16:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .