如何为超市食谱创建包装食谱?

问题描述 投票:0回答:1

我正在尝试使用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 '[email protected]'
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

确保您在元数据中配置依赖项

我想念什么?

chef chef-recipe
1个回答
0
投票

您的问题应该在您当前的工作目录中,根据您的输出行[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"
© www.soinside.com 2019 - 2024. All rights reserved.