Home:ALL Converter>Node available for search before chef-client run

Node available for search before chef-client run

Ask Time:2014-11-07T23:15:37         Author:Itxaka

Json Formatter

Just wondering, if its possible to search for a node before that node has completed the chef-client run.

Going by the chef docs: https://docs.getchef.com/essentials_nodes_chef_run.html

When all of the actions identified by resources in the resource collection have been done, and when the chef-client run finished successfully, the chef-client updates the node object on the Chef server with the node object that was built during this chef-client run. (This node object will be pulled down by the chef-client during the next chef-client run.) This makes the node object (and the data in the node object) available for search.

The chef-client always checks the resource collection for the presence of exception and report handlers. If any are present, each one is processed appropriately

So for example, I have a recipe that searchs for nodes with a role called "webserver". Im creating the chef node via pychef, and filling some attributes, and runlists (including that role in the run_list). Then launching the chef-client from the mahchine, it always fails to find any nodes with that role, as it has not been saved, so its not available for search.

Its easy to see with a knife search as the roles attribute of the returned search are empty (roles are still on the run_list) and when the chef-client finishes, then the roles are moved to the proper place, node.roles.

Is there a way I can force the node to be saved, before doing the search so it will appear in the results? Keeping the chef node in the chef server works, but it could be deleted some day and the search would not work anymore.

Thanks!

Author:Itxaka,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/26804304/node-available-for-search-before-chef-client-run
yy