Только интерфейс lo в /etc/netplan Ubuntu 20.04

Мне удалось связаться с одним из pdshразработчиков и узнать следующее:

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.

Что, кажется, подтверждает то, что уже было установлено в этом посте.

Однако за ним последовал:

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.

В моих собственных тестах у меня были некоторые проблемы с работой именно этого примера:

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

Одна небольшая настройка делает его живым, и это использование «обычного» файла:

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

Заключение:pdshможно было бы расширить функцию, чтобы лучше справляться с тем, о чем я просил, но даже сейчас есть способы добиться того, о чем я просил.

0
02.02.2021, 12:21
0 ответов

Теги

Похожие вопросы