通过 Vagrant 安装多个软件包厨师

发布于 2024-10-23 13:41:13 字数 2042 浏览 9 评论 0原文

我刚刚发现 Vagrant + Chef,我正在尝试创建一个简单的配方来在节点上安装多个包。我认为这样的东西可以工作(我是全新的红宝石):

# (From cookbooks/MY_COOCKBOOK/recipes/default.rb)
# Install required packages
%w{build-essential libncurses5-dev openssl libssl-dev}.each do |pkg|
  package pkg do
    action :install
  end
end

但这失败并出现以下错误:

[default] [Thu, 17 Mar 2011 06:24:27 -0700] INFO: Installing package[libssl-dev] version 0.9.8k-7ubuntu8.5
: stdout
[default] /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/mixin/command.rb:184:in `handle_command_failures': stderr
[default] : : stderr
[default] apt-get -q -y install libssl-dev=0.9.8k-7ubuntu8.5 returned 100, expected 0: stderr
[default]  (: stderr
[default] Chef::Exceptions::Exec: stderr
[default] )
: stderr
[default]   from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/mixin/command.rb:131:in `run_command'
    from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/mixin/command.rb:199:in `run_command_with_systems_locale'
    from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/provider/package/apt.rb:68:in `install_package'
    from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/provider/package.rb:60:in `action_install'
[...]

: stderr
[default] [Thu, 17 Mar 2011 06:24:34 -0700] ERROR: package[libssl-dev] (/tmp/vagrant-chef/cookbooks-0/erlang-src/recipes/default.rb:22:in `from_file') had an error:
apt-get -q -y install libssl-dev=0.9.8k-7ubuntu8.5 returned 100, expected 0
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/mixin/command.rb:184:in `handle_command_failures'
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/mixin/command.rb:131:in `run_command'
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/mixin/command.rb:199:in `run_command_with_systems_locale'
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/provider/package/apt.rb:68:in `install_package'
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/provider/package.rb:60:in `action_install'

我觉得我在这里缺少一些基本的东西......

I've just discovered Vagrant + Chef and I'm trying to create a simple recipe to install multiple packages on the node. I thought something like this could work (I'm completely new tu ruby):

# (From cookbooks/MY_COOCKBOOK/recipes/default.rb)
# Install required packages
%w{build-essential libncurses5-dev openssl libssl-dev}.each do |pkg|
  package pkg do
    action :install
  end
end

But this fails with the following error:

[default] [Thu, 17 Mar 2011 06:24:27 -0700] INFO: Installing package[libssl-dev] version 0.9.8k-7ubuntu8.5
: stdout
[default] /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/mixin/command.rb:184:in `handle_command_failures': stderr
[default] : : stderr
[default] apt-get -q -y install libssl-dev=0.9.8k-7ubuntu8.5 returned 100, expected 0: stderr
[default]  (: stderr
[default] Chef::Exceptions::Exec: stderr
[default] )
: stderr
[default]   from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/mixin/command.rb:131:in `run_command'
    from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/mixin/command.rb:199:in `run_command_with_systems_locale'
    from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/provider/package/apt.rb:68:in `install_package'
    from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/provider/package.rb:60:in `action_install'
[...]

: stderr
[default] [Thu, 17 Mar 2011 06:24:34 -0700] ERROR: package[libssl-dev] (/tmp/vagrant-chef/cookbooks-0/erlang-src/recipes/default.rb:22:in `from_file') had an error:
apt-get -q -y install libssl-dev=0.9.8k-7ubuntu8.5 returned 100, expected 0
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/mixin/command.rb:184:in `handle_command_failures'
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/mixin/command.rb:131:in `run_command'
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/mixin/command.rb:199:in `run_command_with_systems_locale'
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/provider/package/apt.rb:68:in `install_package'
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/provider/package.rb:60:in `action_install'

I've the impression I'm missing something basic here...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

几度春秋 2024-10-30 13:41:13

事实证明,我只是缺少 Vagrantfile 上的“apt”配方,该配方在安装所需的软件包之前运行 apt-get 更新。所以,上面的说法是正确的。

It turned out that I was simply missing the "apt" recipe on my Vagrantfile, which run an apt-get update before installing the required packages. So, the above was correct.

就像说晚安 2024-10-30 13:41:13

只是在这里添加这个答案以供将来参考。如果您遇到必须在调用某些 package 命令之前运行 apt-get update 的情况,您可以求助于以下代码片段:

execute "update package index" do
  command "apt-get update"
  ignore_failure true
  action :nothing
end.run_action(:run)

而且效果很好。

Just adding this answer here for future reference. If you ever run into a situation where you must run apt-get update before calling some package commands, you can resort to this snippet:

execute "update package index" do
  command "apt-get update"
  ignore_failure true
  action :nothing
end.run_action(:run)

And it works fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文