Is knife ssh repeatedly running commands?

Hi,

I was just trying to do a simple comparison of the contents of a configuration directory on quite a few hosts (just over a thousand) to see if they all had similar contents.

I just ran a “ls” against them using knife ssh however instead of getting just over a thousand responses I got tens of thousands of responses. It looks like knife ssh is running “ls” anywhere from 6 to 13 times on the hosts because I got contents of the directory returned 6 to 13 separate lines/parts.

It doesn’t look to be a file name limitation because the contents (as expected) are the same or at least very similar and none of the files have names longer than ten characters. And even if that were the case then I would expect every host to have had the output broken into the same number of lines instead of this seemingly random distribution. Nor do any of the returned lines contain any partial file names. They whole names, some lines have only one file name others have ten file names with no apparent rhyme or reason as to why.

As I said, the command is merely “ls”, nothing fancy. But I wanted to run this through a simple bash script to do some comparisons of the file contents and now I have to join the output of the command randomly split into 6 to 13 lines.

What in the world is going on?

The command is merely, knife ssh 'chef_environment:prod' 'ls'

It shouldn’t do that, unless you have 6-13 different entries in your nodes table per each server (under different node names, but the same hostname/ip address that knife ssh uses).

knife ssh 'chef_environment:prod` 'uname -a`

might be a better command to start with since it should produce only one line per host, and will return the hostname in the output.