Sorry it wasn't helpful, I did misunderstand you. It was actually news to me that search wouldn't work until after the first chef run. I just tried it, and actually search *does* seem to work as soon as the node is created (at least in Chef 12.0.8 with Chef 12.3.0 client). One thing: populate the FQDN. That appears to make a bit of a difference.
Here is what I did:
> knife node create test
> knife node search 'node:test'
Works as expected.
> knife node search 'node:*'
Did not return the new node in one of my test runs, but did in another.
Now add the fqdn attribute:
> knife node edit test
Add the fqdn attribute
Then
> knife node search 'node:*'
Now the new node will show up. Whether this was due to adding the FQDN attribute, or coincidence, I don't know. It may simply take a bit of time for chef to add the new node to search indices.
Kevin Keane
The NetTech
http://www.4nettech.com
Our values: Privacy, Liberty, Justice
See https://www.4nettech.com/corp/the-nettech-values.html
-----Original message-----
From: Douglas Garstang <
">
>
Sent: Saturday 13th June 2015 22:19
To:
">
Subject: [chef] Re: RE: Re: RE: Chef Search for Node Discovery.
Kevin,
Seems we have a slight disconnect. It's been my experience that you can't query anything about a node with chef search, not even the node itself, until after the client has run for the first time. I actually don't need to pull any attributes from the node. This is for zookeeper, so I just need to get a list of host names that match a criteria (role, environment etc).
Alas, I can't use a data bag, or a role. My boot scripts use AWS Dynamodb (and a concatenated role and environment as a key) to pick always incrementing host name numbers. I'd have to start the CF stack, wait until the scripts had queried DynamoDB, had set the Name tag on the instance, eyeball the name in the Amazon console, and then go update the role, upload it to chef etc, before the instance came fully up.
Doug