Run recipe from Chef Client/Node


#1

Hi All,

I have created a chef cookbook/recipe from Chef Workstation. I have uploaded it to Chef server using knife. I have boostrapped the node/client from the workstation and run the cookbook.
Is it possible to run the cookbook recipe from the node itself and not using knife command from workstation.

I want to upload the recipe from workstation but not install the recipe from there. Can we automate the process of bootstrapping and running the cookbook recipe.

Thanks in advance.

Regards,
Gururaj


#2

There are several different permutations on how you could automate this. Essentially you want to include the chef-client install and initial client.rb/validator in your provisioning process. Have a look at Unattended Installs. The idea is that the node “self-bootstraps” on first boot.


#3

I think what you want is from the node run.

chef-client -o ‘recipe[my-cookbook::my-recipe]’

Obviously it will have to be done with a user that has priviledges to run chef-client.

https://docs.chef.io/ctl_chef_client.html