If I have added a chroot (using the Debian schroot package to enter it) on a remote machine, and I normally maintain that machine using the ssh connection plugin, and I want to maintain the chroot as well (it can be considered “as if” it was another machine of its own), then… I have a bit of a conundrum, right?
The Ansible chroot connection is for local chroots only (and only using the chroot(8) command, not schroot).
I think my best bet is to run an sshd in the chroot, on a separate port, and handle it as an actual different machine in the inventory, isn’t it?
Otherwise, I see the following options:
-
fork the ssh connection plugin and make the fork to use schroot; obviously no long-term sustainable option
-
write a become (!) plugin to use
schroot -u rootipvsudo(and possibly contribute it, so it becomes long-term sustainable); this can then be used with the normal ssh connection plugin, but a lot of care must be taken that the directories like/home,/tmp, etc. are bind-mounted 1:1 into the chroot (and anything where anything-in-Ansible puts its files, temporary or not) -
create a different remote user on the server whose shell is a shell script calling a shell in the chroot; this has the downside of that Ansible also uses SFTP to transfer files, so the filesystem hierarchy stuff will be an issue
Does anyone have a better idea?