我正在尝试使用Chef在必须包含PostgreSQL和MsBuild的Ubuntu服务器计算机(18.04)中创建一个环境(我将部署asp.net核心应用程序)。超市中已经有用于设置postgres的食谱,但是我不能使用它们。我是following this tutorial
首先,我创建了一个新的包装食谱:
chef generate cookbook my_postgres
然后我将metadata.rb更改如下:
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'
我的default.rb文件如下:
#
# Cookbook:: my_postgres
# Recipe:: default
#
# Copyright:: 2020, The Authors, All Rights Reserved.
include_recipe 'postgresql::default'
但是当我运行食谱时:
sudo chef-client --local-mode default.rb
我收到以下消息:
[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
确保在元数据中配置依赖项
我想念什么?
答案 0 :(得分:1)
您的问题应该在您当前的工作目录中,根据您的输出行[2020-02-23T16:19:26+00:00] WARN: No cookbooks directory found at or above current directory. Assuming /home/hermano/my_postgres/recipes
在此目录中执行命令。应该是/home/hermano/my_postgres/recipes
根据文档,您必须创建一个名为 cookbooks 的目录,并在其中放置Cookbooks目录:
/home/hermano/cookbooks
/home/hermano/cookbooks/my_postgres
然后,您应该在cookbooks目录上设置cwd并执行以下命令:
cd /home/hermano/cookbooks
sudo chef-client --local-mode --runlist "my_postgres::default.rb"