Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Chef infra 如何为超市菜谱创建包装菜谱?_Chef Infra_Chef Recipe - Fatal编程技术网

Chef infra 如何为超市菜谱创建包装菜谱?

Chef infra 如何为超市菜谱创建包装菜谱?,chef-infra,chef-recipe,Chef Infra,Chef Recipe,我正在尝试使用Chef在Ubuntu服务器机器(18.04)中创建一个必须包含PostgreSQL和MsBuild的环境(我将部署一个asp.net核心应用程序)。超市里已经有烹饪书,但我不能用。我是 首先,我创建了一本新的包装烹饪书: chef generate cookbook my_postgres 然后我将metadata.rb更改为如下所示: name 'my_postgres' maintainer 'The Authors' maintainer_email 'you@examp

我正在尝试使用Chef在Ubuntu服务器机器(18.04)中创建一个必须包含PostgreSQL和MsBuild的环境(我将部署一个asp.net核心应用程序)。超市里已经有烹饪书,但我不能用。我是

首先,我创建了一本新的包装烹饪书:

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
确保在元数据中配置了依赖项


我错过了什么

您的问题应该在当前工作目录上,从该目录执行命令,根据您的输出行
[2020-02-23T16:19:26+00:00]警告:在当前目录或其上找不到cookbooks目录。假设/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"

我觉得自己很愚蠢。就这样,非常感谢。