【发布时间】:2014-11-10 19:17:07
【问题描述】:
我想使用 [chef-rbenv][1] 食谱。
我在 chef-repo 顶级目录中创建了一个 Berksfile,如下所示:
source "https://api.berkshelf.com"
cookbook 'rbenv'
并由berks vendor cookbooks 安装说明书。
然后我在服务器配置 json 文件中添加了一个 "recipe[rbenv::user]"。
根据文档我必须设置一个变量node.default['rbenv']['user_installs'] 来安装rbenv。但我不知道该写在哪里。
谁能告诉我应该在哪里以及如何编写变量?
**我的环境(编辑)
我正在像这样使用local mode:
$ sudo chef-client --local-mode -c solo.rb -j localhost.json
solo.rb
base = File.expand_path('..', __FILE__)
file_cache_path "/tmp/chef-solo"
cookbook_path ["#{base}/site-cookbooks", "#{base}/cookbooks"]
role_path "#{base}/roles"
localhost.json
{
"run_list" : [
"recipe[rbenv::user]"
]
}
伯克斯文件
source "https://api.berkshelf.com"
cookbook 'rbenv'
角色/rbenv.rb
name "rbenv"
default_attributes({
'rbenv' => {
'user_installs' => {
'user' => 'ironsand',
'rubies' => ['1.9.3-p0'],
'global' => '1.9.3-p0',
}
},
})
这是我运行命令时的错误:
Starting Chef Client, version 11.14.6
[2014-09-18T03:56:08+09:00] WARN: Child with name 'vm-mint.json' found in multiple directories: /home/ironsand/my_chef_repo/nodes/vm-mint.json and /home/ironsand/my_chef_repo/nodes/vm-mint.json
resolving cookbooks for run list: ["rbenv::user"]
Synchronizing Cookbooks:
- git
- rbenv
- dmg
- yum-epel
- build-essential
- apt
- windows
- runit
- ohai
- yum
- chef_handler
Compiling Cookbooks...
================================================================================
Recipe Compile Error
================================================================================
Chef::Exceptions::RecipeNotFound
--------------------------------
could not find recipe user for cookbook rbenv
Running handlers:
[2014-09-18T03:56:10+09:00] ERROR: Running exception handlers
Running handlers complete
[2014-09-18T03:56:10+09:00] ERROR: Exception handlers complete
[2014-09-18T03:56:10+09:00] FATAL: Stacktrace dumped to /tmp/chef-solo/chef-stacktrace.out
Chef Client failed. 0 resources updated in 3.019030351 seconds
[2014-09-18T03:56:10+09:00] ERROR: could not find recipe user for cookbook rbenv
[2014-09-18T03:56:10+09:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
【问题讨论】:
标签: chef-infra berkshelf berksfile