Jean-Marie Bolle
Jean-Marie Bolle

Reputation: 1

chef client using policyfile : could not find recipe default for cookbook

I am using chef open source version 13.6.4 and get stuck on a problem I can't solve with Policyfile. I created one simple Policyfile based on the simplest possible cookbook given below (cookbooks\test_prospero\default.rb)

root_install_path = 'e:\\prospero'.freeze
node_fqdn = node['fqdn'].to_s.downcase
Chef::Log.info "Detected node : #{node_fqdn}"

The Policyfile.rb is:

name "test_prospero"
default_source :chef_repo, '../'
run_list "test_prospero::default"
cookbook "test_prospero"

I installed the policyfile with the following result:

Microsoft Windows [Version 10.0.16299.192]
(c) 2017 Microsoft Corporation. All rights reserved.

c:\chef-data\chef-repo\policies>chef install
Building policy test_prospero
Expanded run list: recipe[test_prospero::default]
Caching Cookbooks...
Installing test_prospero 0.1.2

Lockfile written to c:/chef-data/chef-repo/policies/Policyfile.lock.json
Policy revision id: 4e4b44089fe5a4ccd6656d419153e6d642d21c3392be2f74126b69f477c59118

And pushed it on the server:

Uploading policy to policy group build-group
Using    test_prospero 0.1.2 (8232678b)

c:\chef-data\chef-repo\policies>chef show-policy

test_prospero
=============

* build-group:  4e4b44089f

Once run on one already bootstrapped node with the following configuration client.rb:

chef_server_url            "https://chef.sage.ch/organizations/sage-system"
validation_client_name     "sage-system-validator"
file_cache_path            "c:/chef/cache"
file_backup_path           "c:/chef/backup"
cache_options              ({:path => "c:/chef/cache/checksums", :skip_expires => true})
node_name                  "Prospero-9.9.9-RELEASE-Deploy-S1VW1730"
log_level                  :info
log_location               STDOUT
trusted_certs_dir          "c:/chef/trusted_certs"
policy_name                "test_prospero"
policy_group               "build-group"
use_policyfile             true
policy_document_native_api true
current_version = Gem::Version.new(Chef::VERSION)
unless Gem::Requirement.new(">= 12.7").satisfied_by?(current_version)
  puts("!" * 80)
  puts(<<-MESSAGE)
This Chef Repo requires features introduced in Chef 12.7, but you are using
Chef #{Chef::VERSION}. Please upgrade to Chef 12.7 or later.
MESSAGE
  puts("!" * 80)
  exit!(1)
end

Running chef-client on dos prompt I got following error:

c:\>chef-client
Starting Chef Client, version 13.6.4
[2018-01-29T16:48:48+01:00] INFO: *** Chef 13.6.4 ***
[2018-01-29T16:48:48+01:00] INFO: Platform: x64-mingw32
[2018-01-29T16:48:48+01:00] INFO: Chef-client pid: 3288
[2018-01-29T16:48:48+01:00] INFO: The plugin path C:\chef\ohai\plugins does not exist. Skipping...
Using policy 'test_prospero' at revision '4e4b44089fe5a4ccd6656d419153e6d642d21c3392be2f74126b69f477c59118'
[2018-01-29T16:48:55+01:00] INFO: Run List is [["recipe[test_prospero::default]"]]
[2018-01-29T16:48:55+01:00] INFO: Run List expands to [test_prospero::[email protected] (8232678)]
[2018-01-29T16:48:55+01:00] INFO: Starting Chef Run for Prospero-9.9.9-RELEASE-Deploy-S1VW1730
[2018-01-29T16:48:55+01:00] INFO: Running start handlers
[2018-01-29T16:48:55+01:00] INFO: Start handlers complete.
[2018-01-29T16:48:55+01:00] INFO: Error while reporting run start to Data Collector. URL: https://chef.sage.ch/organizations/sage-system/data-collector Exception: 404 -- 404 "Not Found"  (This is n
al if you do not have Chef Automate)
resolving cookbooks for run list: ["test_prospero::[email protected] (8232678)"]
[2018-01-29T16:48:55+01:00] INFO: Loading cookbooks [[email protected]]
Synchronizing Cookbooks:
Installing Cookbook Gems:
Compiling Cookbooks...

================================================================================
Recipe Compile Error
================================================================================

Chef::Exceptions::RecipeNotFound
--------------------------------
could not find recipe default for cookbook test_prospero

System Info:
------------
chef_version=13.6.4
platform=windows
platform_version=6.3.9600
ruby=ruby 2.4.2p198 (2017-09-14 revision 59899) [x64-mingw32]
program_name=C:/opscode/chef/bin/chef-client
executable=C:/opscode/chef/bin/chef-client


Running handlers:
[2018-01-29T16:48:55+01:00] ERROR: Running exception handlers
Running handlers complete
[2018-01-29T16:48:55+01:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 06 seconds
[2018-01-29T16:48:55+01:00] FATAL: Stacktrace dumped to c:/chef/cache/chef-stacktrace.out
[2018-01-29T16:48:55+01:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2018-01-29T16:48:55+01:00] FATAL: Chef::Exceptions::RecipeNotFound: could not find recipe default for cookbook test_prospero

I tried various default_source configurations, and also run it with chef zero using the export, without problems, read the doc and others sites (for instance YoloVer) and no one seems to have had the same situation.

The same cookbook running without using policyfile does not produce any error!

c:\>chef-client -o test_prospero
Starting Chef Client, version 13.6.4
[2018-01-29T17:19:55+01:00] INFO: *** Chef 13.6.4 ***
[2018-01-29T17:19:55+01:00] INFO: Platform: x64-mingw32
[2018-01-29T17:19:55+01:00] INFO: Chef-client pid: 816
[2018-01-29T17:19:55+01:00] INFO: The plugin path C:\chef\ohai\plugins does not exist. Skipping...
[2018-01-29T17:20:01+01:00] WARN: Run List override has been provided.
[2018-01-29T17:20:01+01:00] WARN: Original Run List: []
[2018-01-29T17:20:01+01:00] WARN: Overridden Run List: [recipe[test_prospero]]
[2018-01-29T17:20:01+01:00] INFO: Run List is [recipe[test_prospero]]
[2018-01-29T17:20:01+01:00] INFO: Run List expands to [test_prospero]
[2018-01-29T17:20:01+01:00] INFO: Starting Chef Run for Prospero-9.9.9-RELEASE-Deploy-S1VW1730
[2018-01-29T17:20:01+01:00] INFO: Running start handlers
[2018-01-29T17:20:01+01:00] INFO: Start handlers complete.
[2018-01-29T17:20:02+01:00] INFO: Error while reporting run start to Data Collector. URL: https://chef.sage.ch/organizations/sage-system/data-collector Exception: 404 -- 404 "Not Found"  (This is norm
al if you do not have Chef Automate)
resolving cookbooks for run list: ["test_prospero"]
[2018-01-29T17:20:02+01:00] INFO: Loading cookbooks [[email protected]]
[2018-01-29T17:20:02+01:00] INFO: Skipping removal of obsoleted cookbooks from the cache
Synchronizing Cookbooks:
[2018-01-29T17:20:02+01:00] INFO: Storing updated cookbooks/test_prospero/metadata.rb in the cache.
[2018-01-29T17:20:02+01:00] INFO: Storing updated cookbooks/test_prospero/README.md in the cache.
[2018-01-29T17:20:02+01:00] INFO: Storing updated cookbooks/test_prospero/chefignore in the cache.
[2018-01-29T17:20:02+01:00] INFO: Storing updated cookbooks/test_prospero/recipes/default.rb in the cache.
  - test_prospero (0.1.2)
Installing Cookbook Gems:
Compiling Cookbooks...
[2018-01-29T17:20:02+01:00] INFO: Detected node : s1vw1730.sage.ch
Converging 0 resources
[2018-01-29T17:20:02+01:00] WARN: Skipping final node save because override_runlist was given
[2018-01-29T17:20:02+01:00] INFO: Chef Run complete in 0.896052 seconds
[2018-01-29T17:20:02+01:00] INFO: Skipping removal of unused files from the cache

Running handlers:
[2018-01-29T17:20:02+01:00] INFO: Running report handlers
Running handlers complete
[2018-01-29T17:20:02+01:00] INFO: Report handlers complete
Chef Client finished, 0/0 resources updated in 07 seconds

Have you any clue or solution to this problem? Many thanks for your help.

Upvotes: 0

Views: 1294

Answers (1)

coderanger
coderanger

Reputation: 54249

Recipes have to be in a recipes/ subfolder within the cookbook, so cookbooks\test_prospero\recipes\default.rb.

Upvotes: 0

Related Questions