Using ansible to help manage my collection of raspberry pi’s. One in particular is running an “embedded” version of the OS that doesn’t have the normal temp directory. Is there any way in my inventory file to specify where the temp directory is for this computer?
Here’s the output I receive when attempting an ad-hoc ‘uptime’ command:
eyepi | UNREACHABLE! => {
“changed”: false,
“msg”: “Failed to create temporary directory. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in "/tmp", for more error information use -vvv. Failed command was: ( umask 77 && mkdir -p "echo /root/.ansible/tmp"&& mkdir "echo /root/.ansible/tmp/ansible-tmp-1672762692.032167-4139-89985814812145" && echo ansible-tmp-1672762692.032167-4139-89985814812145="echo /root/.ansible/tmp/ansible-tmp-1672762692.032167-4139-89985814812145" ), exited with result 127”,
Thanks – this seemed like exactly what I was hoping to find/hear. When I edit my inventory file to include this, though, I get the same end result. Here’s the specific error:
eyepi | UNREACHABLE! => {
“changed”: false,
“msg”: “Failed to create temporary directory. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in "/tmp", for more error information use -vvv. Failed command was: ( umask 77 && mkdir -p "echo /tmp"&& mkdir "echo /tmp/ansible-tmp-1672839839.263514-8286-43205166856478" && echo ansible-tmp-1672839839.263514-8286-43205166856478="echo /tmp/ansible-tmp-1672839839.263514-8286-43205166856478" ), exited with result 127”,
“unreachable”: true
}
Without that change, the message is different in that the path is different:
eyepi | UNREACHABLE! => {
“changed”: false,
“msg”: “Failed to create temporary directory. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in "/tmp", for more error information use -vvv. Failed command was: ( umask 77 && mkdir -p "echo /root/.ansible/tmp"&& mkdir "echo /root/.ansible/tmp/ansible-tmp-1672840043.972852-8434-37499021304293" && echo ansible-tmp-1672840043.972852-8434-37499021304293="echo /root/.ansible/tmp/ansible-tmp-1672840043.972852-8434-37499021304293" ), exited with result 127”,
“unreachable”: true
}
Which of course makes sense. Now, when I manually ssh to that host, with the same stored credentials (root), I can make new directories in /tmp so it seems like it ought to work. I confess I am not a shell scripting wizard, so I get a little lost trying to follow exactly what’s happening with the various echos in there, one of which appears to be using a relative path instead of absolute. The result 127 – is that ansible specific? If not, google tells me it’s “command not found” but the only commands I see there are umask, mkdir, and echo, all of which I tried and exist.
The message is outdated, 'ansible.cfg' is not the only way to
configure this, your shell plugin (sh in this case) is configurable in
many ways, ansible.cfg is just one, you can also set a environment
variable or an ansible variable (this last one can go in many scopes,
from per run to per host and everything in between).
Thanks, Brian. I appreciate that the error message is outdated, but I’m still confused about what the actual problem is in this case. When I did add the ansible_remote_tmp variable to the inventory, it did seem to have some of the desired effect, in that the paths reported in the error message seemed to reflect that path, except for the one path that appeared to be a relative path (don’t know why).
To recap: I added the var to the inventory line for that computer, and it had an effect but didn’t solve the problem. The error reported is a 127, and of course error numbers need a context. If this is looked in the context of general linux errors, 127 would appear to indicate that the command isn’t found. My reading of the command we were attempting to execute is that the only commands in that string are umask, mkdir, and echo, and if I ssh to the computer in question I can execute all of those with no problem. And yes, I am connecting as the same user that ansible is using. But perhaps the 127 is an ansible error and means something different (though my googling tends to suggest this is not the case). I’m sort of lost in either case.