Saving automatic attributes to chef-server without running chef-client


#1

Hi,

I’m using the Chef search API to search and return automatic attributes (generated via ohai). I’m interested in things like kernel and package versions to help me with software patching.

I’d like to be able to trigger a chef node to recollect those automatic attributes and save them to the chef server. I know a full chef-client run will perform this, but ideally there would be a method that couldn’t make state changes on a node. I administer a chef-server, but don’t maintain the client nodes. It’s inappropriate for me to run chef-client without permission.

I’ve tried running chef-client with an empty run-list, but discovered that does not save a node to chef server.
see https://tickets.opscode.com/browse/CHEF-3506 and CHEF-3506 - Don’t save the node object when using an override run list?

Regarding discussion on CHEF-3506, I understand that partial runs of chef-client shouldn’t update the node on the chef-server. Perhaps automatic attributes are different though as they operate independently of run lists.

Another option would be to write custom tooling to take the result of an ohai shell command and HTTP PUT it to the chef server using the client’s key.

Thoughts / suggestions?

Phil


#2

Make a recipe that grabs the node object, copies over the current attributes that you care about, and then save that modified node (not the current global one) back to the server, and then run that with -o. Anything else risks the server seeing weird and out of context data. This could still be out of sync, if you have plugins deployed by cookbooks though.


#3

Thanks for the idea. I’ll take a look at implementing that.

Phil