Is there a way I can ssh to odd numbered hosts?
this works:
# knife ssh "webhost1*" "chef-client"
this does not work
# knife ssh "webhost1[13579]" "chef-client"
Is there a way I can ssh to odd numbered hosts?
this works:
# knife ssh "webhost1*" "chef-client"
this does not work
# knife ssh "webhost1[13579]" "chef-client"
To achieve this natively, you'll need to look at other properties of node that can be searched. Like roles, tags, etc. One way is to tag the nodes. For example, we can tag the nodes as
oddandeven, i.e.webhost1[13579]will be tagged as odd.Then the odd hosts can be targeted by:
Generating odd numbers for the
knife sshcommand to use is more of a Shell functionality, e.g.:The
seqcommand will generate a sequence starting from1with increments of2, till10. Note that this makes the SSH execution serial, and there may be better or more efficient ways to generate the odd numbers. Also, you can use a similarforloop to tag the nodes if required. Example: