I am trying to use Chef to create an environment in an Ubuntu Server Machine (18.04) that must contain PostgreSQL and MsBuild (I will deploy an asp.net core app). There are already cookbooks for setting up postgres in the supermarket, but I can't use them. I am following this tutorial
First I created a new wrapper cookbook:
chef generate cookbook my_postgres
Then I changed the metadata.rb to look like this:
name 'my_postgres'
maintainer 'The Authors'
maintainer_email 'you@example.com'
license 'All Rights Reserved'
description 'Installs/Configures my_postgres'
long_description 'Installs/Configures my_postgres'
version '0.1.0'
chef_version '>= 13.0'
depends 'postgresql'
And my default.rb file is as follows:
#
# Cookbook:: my_postgres
# Recipe:: default
#
# Copyright:: 2020, The Authors, All Rights Reserved.
include_recipe 'postgresql::default'
But when I run the recipe:
sudo chef-client --local-mode default.rb
I receive the following message:
[2020-02-23T16:19:26+00:00] WARN: No config file found or specified on command line, using command line options.
[2020-02-23T16:19:26+00:00] WARN: No cookbooks directory found at or above current directory. Assuming /home/hermano/my_postgres/recipes.
Starting Chef Client, version 14.7.17
resolving cookbooks for run list: []
Synchronizing Cookbooks:
Installing Cookbook Gems:
Compiling Cookbooks...
[2020-02-23T16:19:28+00:00] WARN: MissingCookbookDependency:
Recipe `postgresql::default` is not in the run_list, and cookbook 'postgresql'
is not a dependency of any cookbook in the run_list. To load this recipe,
first add a dependency on cookbook 'postgresql' in the cookbook you're
including it from in that cookbook's metadata.
Running handlers:
[2020-02-23T16:19:28+00:00] ERROR: Running exception handlers
Running handlers complete
[2020-02-23T16:19:28+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 01 seconds
[2020-02-23T16:19:28+00:00] FATAL: Stacktrace dumped to /home/hermano/.chef/local-mode-cache/cache/chef-stacktrace.out
[2020-02-23T16:19:28+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2020-02-23T16:19:28+00:00] FATAL: Chef::Exceptions::CookbookNotFound: Cookbook postgresql not found. If you're loading postgresql from another cookbook, make sure y
make sure you configure the dependency in your metadata
What Am I missing?
Your issue should be on your current working directory from where you execute your command that according to your output line [2020-02-23T16:19:26+00:00] WARN: No cookbooks directory found at or above current directory. Assuming /home/hermano/my_postgres/recipes
. should be /home/hermano/my_postgres/recipes
According to the documentation you have to create a directory named cookbooks and put there your cookbooks directory:
/home/hermano/cookbooks
/home/hermano/cookbooks/my_postgres
Then you should set your cwd on the cookbooks directory and execute the following:
cd /home/hermano/cookbooks
sudo chef-client --local-mode --runlist "my_postgres::default.rb"