I am unable to write to a block device /dev/sdb3 mounted as /media/ajaved/PIROOT using Ansible chroot connection. I am using Ubuntu Jammy (22.04) as host OS and my Ansible version is 2.10.8.
Mount point:
/dev/sdb3 on /media/ajaved/PIROOT type ext4 (rw,nosuid,nodev,relatime,errors=remount-ro,uhelper=udisks2)
Please see the error below after running Ansible playbook:
pikvm3 unreachable | 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/.ansible-${USER} `"&& mkdir "` echo /tmp/.ansible-${USER}/ansible-tmp-1714377996.3163822-9271-11225315534968 `" && echo ansible-tmp-1714377996.3163822-9271-11225315534968="` echo /tmp/.ansible-${USER}/ansible-tmp-1714377996.3163822-9271-11225315534968 `" ), exited with result 126
We have set remote_tmp to /tmp/.ansible-${USER} in ansible.cfg file. My SUDO_USER ajaved is also in disk group.
Any help is much appreciated. Thanks
Sorry if this is a stupid question but you are aware that the chroot connection only works locally and that if you are working on a remote server you have to run Ansible on the remote server?
I am not working on a remote server. The block device (SD memory card) is attached and mounted locally to my computer where I run Ansible with chroot connection.
Does this answer your question?
Thanks for clarifying that, does the /media/ajaved/PIROOT/tmp directory exist?
What does ls -lah /media/ajaved/PIROOT return?
Does it work if you run the playbook as root? I’ve just checked how I use the chroot plugin – on remote servers – and I always run Ansible as root and don’t have remote_tmp set.
After some debugging, I managed to fix the issue. It was due to QEMU user emulation packages missing in my host OS. So, I basically installed qemu-user and qemu-user-static through APT package manager and Ansible was then able to create TMPDIR using chroot.