Domanda

Ho appena scoperto Vagrant + Chef e sto cercando di creare una ricetta semplice da installare più pacchetti sul nodo. Ho pensato che qualcosa di simile potrebbe funzionare (io sono del tutto nuovo 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

Ma questo non riesce con il seguente errore:

[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'

Ho l'impressione che mi manca qualcosa di base qui ...

È stato utile?

Soluzione

Si è scoperto che stavo semplicemente mancava la ricetta "apt" sul mio Vagrantfile, che corrono un apt-get update prima di installare i pacchetti necessari. Quindi, quanto sopra è stato corretto.

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top