Search code examples
chef-infradevopschef-recipe

Chef error in Cookbook. Missing cookbook with knife


I'm new to Chef world, currently trying to write a cookbook with a single recipe to install a Nagios NRPE on windows server. where I included a bash script in the recipe to execute a set of commands.

However when I run kitchen converge, I constantly receive the below error. I tried lot of variations in "recipie", going through stack-overflow and other online forums which didn't work

please help.

Please let me know if any additional details required

Recipe

 execute 'setup.bash' do     
 cwd '\templates\Setup.bash.sh'  
 command './setup.bash.sh' end

error

> ================================================================================
>        Error Resolving Cookbooks for Run List:
>        ================================================================================
> 
>        Missing Cookbooks:
>        ------------------
>        No such cookbook: Nagios_NRPE
> 
>        Expanded Run List:
>        ------------------
>        * Nagios_NRPE::default
> 
>        System Info:
>        ------------
>        chef_version=15.3.14
>        platform=windows
>        platform_version=6.2.9200
>        ruby=ruby 2.6.4p104 (2019-08-28 revision 67798) [x64-mingw32]
>        program_name=C:/opscode/chef/bin/chef-client
>        executable=C:/opscode/chef/bin/chef-client
> 
> 
>        Running handlers:
>        [2019-10-14T00:18:38+00:00] ERROR: Running exception handlers
>        Running handlers complete
>        [2019-10-14T00:18:38+00:00] ERROR: Exception handlers complete
>        Chef Infra Client failed. 0 resources updated in 04 seconds
>        [2019-10-14T00:18:38+00:00] FATAL: Stacktrace dumped to /kitchen/cache/chef-stacktrace.out
>        [2019-10-14T00:18:38+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
>        [2019-10-14T00:18:38+00:00] FATAL: Net::HTTPServerException: 412 "Precondition Failed"
> >>>>>> ------Exception-------
> >>>>>> Class: Kitchen::ActionFailed
> >>>>>> Message: 1 actions failed.
> >>>>>>     Converge failed on instance <default-windows-2012>.  Please see .kitchen/logs/default-windows-2012.log for more details
> >>>>>> ----------------------
> >>>>>> Please see .kitchen/logs/kitchen.log for more details

Solution

  • make sure that you state your cookbook dependencies within your cookbook metadata.rb, such as

    # metadata.rb
    depends "Nagios_NRPE"
    

    though, seems that you meant nrpe and not Nagios_NRPE.

    make sure knife cookbooks_path is configured correctly.

    now depends how you handle cookbook dependencies, whether it is chef (using a Policyfile or berkshelf (using a Berksfile), make sure to download cookbook dependencies.