I was able to get in contact with one of the pdsh
developers and learned the following:
What you want is "stdin broadcast" and unfortunately support for this
was never added to pdsh. It would be a nice feature, but there was not
historically much need for it, so it wasn't ever done.
Which seem to confirm what has already been established in this post.
However, it was followed by:
BTW, it isn't that it is impossible to do the stdin broadcast.
Parallel launchers that are part of HPC schedulers can do it, like
srun(1) and the like. The mechanism is that stdin is read in once,
then copied to a buffer for each remote process, i.e. the duplication
is done inside of the parallel launcher.
The reason for the follow-up is that there are some misleading answers
on that stackexchange post.
Another way to get around the serial for-loop problem would be to run
ssh from GNU parallel or pdsh -R exec. Example with pdsh -R exec:
$ pdsh -R exec -w host[0-10] bash -c 'ssh %h cat < <(echo test)'
Of course the drawback here is that you are creating the temporary
file for redirection N times. Might be better to put your output into
a local file and then just cat that file to each ssh command.
The benefit of pdsh/parallel over a for loop is that you get the
parallelism.
In my own tests I had some trouble getting that exact example working:
root@master# pdsh -R exec -w host1 bash -c 'ssh %h cat < <(echo test)'
host1: bash: -c: line 0: syntax error near unexpected token `<'
host1: bash: -c: line 0: `ssh n1 cat < <(echo test)'
pdsh@master: host1: bash exited with exit code 1
One small tweak gets it alive, and that is using a "normal" file:
root@master# cat data.txt
test from file
root@master# pdsh -R exec -w host1 bash -c 'ssh %h cat < data.txt'
host1: test from file
Conclusion: pdsh
could grow a feature to handle what I was asking for better, but even as it is now there are ways to achieve what I asked for.