Reputation: 161
I can't seem to get knife ssh/search to expand a range of hostnames that differ only by number. For example, if I have host1.example.com, host2.example.com, host3.example.com,...host50.example.com I can't get either of these two queries using knife's range to work properly, e.g.,
knife ssh 'name:[host1.example.com TO name:host50.example.com]'
or
knife ssh 'name:host[1 TO 50].example.com'
In the first case I just getting the beginning host and the end host returned. In the latter case I get the following error message
ERROR: The data in your request was invalid
Response: invalid search query
The hosts otherwise do not differ, i.e, by role nor environments, so I'm forced to use name. And it's more than a little tedious to type something like,
knife ssh 'name:host1.example.com OR name:host2.example.com OR name:host3.example.com...OR name:host50.example.com
Any suggestions?
Upvotes: 1
Views: 509
Reputation: 1
I've used variations of this to do my work, as oppose to doing iterative calls to knife ssh.
NODES=""
for i in {01..50}
do
if [ ! -z "${NODES} ]; then
NODES="${NODES} or name:<hostprefix>${i}"
else
NODES="name:<hostprefix>${i}"
fi
done
knife ssh "${NODES} -x user -i ~/.ssh/key.pem "some command'
Upvotes: 0
Reputation: 54211
Ranges in search queries don't work in a useful way. Remember that Solr is built for text search and that we cram all attributes into a single facet. You'll have to use a mix of wild cards and local filtering.
Upvotes: 2