Using chef api to perform task

Is there any chef-api to create data bag item and assign role to the run-list and then run chef-client via this api.
We need to use chef-api with node.js so that node.js application can create data bag item and then assign role to the node’s runlist and then run chef-client.
Please suggest the api for running chef-client

I’d urge you to rethink your workflow in terms of cookbooks and recipes. First recipe generates or populates a data bag, which can exist on the local server and is not necessarily published to the chef server. Second recipe runs whatever operations, recipes, or roles might use that data bag.

It’s when the data bag needs to be published out of band the chef client, for security or customized configuration reasons, that life gets weird. And you’ll probably also want to think about the logic of “what if I don’t have the data bag”. I’ve certainly used the absence of a data bag in recipes to report the absence, but allow other recipes to continue instead of failing outright.

1 Like

Is there a way to run chef-client from node.js box to execute chef-client on the node ?
is there any npm api to do so?