简体   繁体   中英

ChefDK Policyfile workflow - how to upload third-party cookbooks?

I'm trying to make sense out of Policyfile workflow with Chef Server.

So far so good, I'm at the point where lock file is generated and "chef provision" correctly picks up the provisioning cookbooks and starts the converge process.

However, there seems to be no "berks install / berks vendor / knife upload" equivalent with Policyfiles - none of the third-party cookbooks are uploaded to Chef server during "chef push". Therefore, "chef provision" command quite obviously fails with "cannot find cookbooks" error.

Here's the snippet of my Policyfile:

name "policy-test"
# Where to find external cookbooks:
default_source :supermarket
run_list "role[my-book::default]"

cookbook 'my-book', path: './cookbooks/my-book'
cookbook 'java'
cookbook 'chef-teamcity'

When I run "chef push DEV", only "my-book" gets uploaded to Chef server, but none of the others (although they are getting properly mentioned in Policyfile.lock). Is this correct behaviour, or I am doing something wrong?

In the meantime, I have resorted to Berksfile and knife to upload dependencies as a workaround, but this removes a lot of value from having Policyfile in the first place.

Is there a way to make "chef push" upload third-party cookbooks?

Many thanks in advance.

UPDATE:

I have replaced role with recipe, but it still does not work:

 Starting Chef Client, version 12.13.37
                      resolving cookbooks for run list: ["my-book::default"]

                      ================================================================================
                      Error Resolving Cookbooks for Run List:
                      ================================================================================

                      Missing Cookbooks:
                      ------------------
                      The following cookbooks are required by the client but don't exist on the server:
                      * my-book

Still have to use berks upload / knife upload workaround.

Is this relevant to this issue? https://github.com/chef/chef-dk/issues/901

You can't really use roles with Policyfiles as the policy itself replaces the concept of roles. The push uses the run list to know what to upload, any cookbooks mentioned in the run list or dependencies thereof will be uploaded. In this case you probably want to switch that to recipe[my-book] and instead of listing those two cookbooks in the policy, add them as dependencies in my-book/metadata.rb . Check out https://yolover.poise.io/ for a more complete walkthrough.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM