Run cookbook with chief-client in local mode

All cookbooks should be placed in cookbooks folder.

[root@box-16039 cookbooks]# pwd

/root/cookbooks

[root@box-16039 cookbooks]# cat config.rb

local_mode true
cookbook_path [
'/root/cookbooks'
]

Create cookbook in subfolder:
[root@box-16039 vpsdeploy]# pwd

/root/cookbooks/vpsdeploy

[root@box-16039 vpsdeploy]# ls

Berksfile chefignore files LICENSE metadata.rb README.md recipes spec test vpsdeploy.json

[root@box-16039 cookbooks]# cat vpsdeploy/vpsdeploy.json
Create json file with cookbooks runlist (in JSON format)

{"run_list": ["recipe[vpsdeploy::default]"]}

Run recipe with following parameters:

chef-client -j ~/cookbooks/vpsdeploy/vpsdeploy.json --local-mode

If needed add in metadata.rb of the main cookbook dependencies:

depends 'mysql', '~> 8.0'

And place cookbooks in ~/cookbooks folder.

Leave a Reply