Search code examples
sshchef-infraknife

Is there a way to run knife ssh on hosts provided in a file?


While adding a bunch of fresh hosts to an existing role, I wanted to run chef-client on just the new hosts.

Is there a way to do a knife ssh and provide the host list in a local file ? Because if I refer to the role, it will run on all the (new+existing) hosts.


Solution

  • As @Tejay mentioned, your recipes should be idempotent, so you do not need to worry about "unneeded" chef run on some nodes.

    Soulution to run ssh knife ssh on exact list of the server is to make search query that matches all your nodes, like:

    knife ssh 'name:server01 OR name:server02 OR ..'
    

    Or to use manual-list flag (check the knife ssh doc)

    -m, --manual-list
    Use to define a search query as a space-separated list of servers.
    If there is more than one item in the list, put quotes around the
    entire list. For example: --manual-list "server01 server 02 server 03 .."