In a template I want to change the user ID from 1000 to something else:
root@templatevm:~# usermod -u 1005 user
usermod: user user is currently used by process 691
Ok. Maybe then I might try stepping back to single user mode rather than whack-a-mole with running user processes that auto restart:
[user@dom0 ~]$ qvm-run --pass-io -u root templatevm "systemctl isolate rescue.target"
[user@dom0 ~]$ qvm-run --pass-io -u root templatevm "ls"
2025-11-16 11:33:24.521 qrexec-client[408964]: qrexec-daemon-common.c:232:connect_unix_socket: connect /var/run/qubes/qrexec.templatevm: No such file or directory
2025-11-16 11:33:24.521 qrexec-client[408964]: qrexec-daemon-common.c:29:negotiate_connection_params: write daemon: Bad file descriptor
… Not too surprising this didn’t work (even with --no-gui).
What does work is to reboot and login to a root console with qvm-console-dispvm and then type in my admin commands there. But that’s not scriptable, I don’t think. I could also bypass usermod and/or groupmod and just edit /etc/passwd and /etc/group directly:
You’re surely right. I’ve been able to evade salt for template shaping and qube orchestration for years now through abuse of qvm-run. I like the non-abstraction and easy debugging and composability of shell scripting, but there is a limit, and this at least rubs up against it.
Anyway, here’s a race-y and wrong way to do it that works:
I wonder what the equivalent Ansible solution would look like. Not that a third solution is needed, but it would be interesting in a Rosetta Stone sense.
So the code/conf is really quite similar, which makes sense, both of them being YAML-ish, and the material distinctions between the technologies being largely backend/architectural.