English 中文(简体)
Installing multiple packages via Vagrant + Chef
原标题:

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...

最佳回答

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.

问题回答

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.





相关问题
How can I see all the data that solr is indexing?

So I have a solr server running as part of a chef server. Some of my nodes just aren t coming up in searches. I can use ?q=*:* to show the documents but most of the chef data is indexed as ...

Should I be using Chef or other tool for managing servers

I have 4 servers behind a load balancer and a staging server, a db server, and a utility server for a web application that hosts a number of web sites. Should I make the jump to Chef to manage these ...

Storing passwords in Chef?

What is the best practice for storing password and API keys with Chef? It s really tempting to store database passwords, AWS api keys, and other sensitive credentials as Chef Server Attributes for ...

Do I have use of Chef if I m using Heroku?

I use Heroku to deploy my Rails apps. But I thought about learning Chef to automatically set up the development infrastructure, but Im not sure. So to put it very simple, are there any reasons for ...

chef-solo example

We are learning chef-solo and need a good example for better understanding.. Have searched a lot on net but the ideas are very confusing. can anyone suggest some examples.. and also how to run them.. ...

Cfengine vs Chef

What are the differences in term of features between Cfengine and Chef?

热门标签