So multiple ssh subprocesses should not be a huge issue, you could after all use ControlMaster and stuff to reuse the connection.
That said, it seems reasonable to create a shell script, or a Python script and execute that on the remote from stdin.
python3 and python3-apt should be available on all systems I think to do config lookups, and the content of files can be embedded into a generated script in base64.
That said, it would be an entirely different code path which I think might be worse than it maybe not working if the remote is at an older version.
So multiple ssh subprocesses should not be a huge issue, you could after all use ControlMaster and stuff to reuse the connection.
That said, it seems reasonable to create a shell script, or a Python script and execute that on the remote from stdin.
python3 and python3-apt should be available on all systems I think to do config lookups, and the content of files can be embedded into a generated script in base64.
That said, it would be an entirely different code path which I think might be worse than it maybe not working if the remote is at an older version.