Chef Opscode apt livro de receitas - apt-get install retornou 100, esperado 0

2

Estou executando o Chef solo (versão 11.4.0) em um VPS limpo com o Ubuntu 12 instalado, e estou tendo alguns problemas com apt . O problema é que qualquer comando package gerou um erro:

Chef::Exceptions::Exec
----------------------
apt-get -q -y install update-notifier-common=0.126 returned 100, expected 0

Mas, executar esse comando no shell funcionou perfeitamente.

Depois de investigar por um tempo, descobri que as pessoas recomendavam executar Opscode apt cookbook (versão 1.9.0 ) na lista de execução antes de qualquer livro de receitas. Dessa forma, alguns problemas com apt-get update cache foram resolvidos.

Por isso, coloco na minha lista de execução o livro de receitas apt primeiro e ainda estou com os mesmos erros:

Recipe: apt::default
* execute[apt-get-update] action run
  - execute apt-get update
* execute[apt-get update] action nothing (up to date)
* execute[apt-get autoremove] action nothing (up to date)
* execute[apt-get autoclean] action nothing (up to date)
* package[update-notifier-common] action install

================================================================================
Error executing action 'install' on resource 'package[update-notifier-common]'
================================================================================

Chef::Exceptions::Exec
----------------------
apt-get -q -y install update-notifier-common=0.126 returned 100, expected 0

Resource Declaration:
---------------------
# In /home/ubuntu/.chef/toldo-cookbooks/cookbooks/apt/recipes/default.rb

 48: package "update-notifier-common" do
 49:   notifies :run, resources(:execute => "apt-get-update"), :immediately
 50: end
 51:

Compiled Resource:
------------------
# Declared in /home/ubuntu/.chef/toldo-cookbooks/cookbooks/apt/recipes/default.rb:48:in 'from_file'

package("update-notifier-common") do
  action :install
  retries 0
  retry_delay 2
  package_name "update-notifier-common"
  version "0.126"
  cookbook_name :apt
  recipe_name "default"
end

[2013-02-24T19:31:10+00:00] ERROR: Running exception handlers
[2013-02-24T19:31:10+00:00] ERROR: Exception handlers complete
Chef Client failed. 1 resources updated
[2013-02-24T19:31:10+00:00] FATAL: Stacktrace dumped to /home/ubuntu/.chef/toldo-cookbooks/chef-stacktrace.out
[2013-02-24T19:31:10+00:00] FATAL: Chef::Exceptions::Exec: package[update-notifier-common] (apt::default line 48) had an error: Chef::Exceptions::Exec: apt-get -q -y install update-notifier-common=0.126 returned 100, expected 0

Você tem alguma pista de onde eu posso continuar minha investigação?

Muito obrigado!

    
por blat 25.02.2013 / 08:10

1 resposta

1

Pode estar relacionado à falta de privilégios:

$ id
uid=1000(gaizka)
$ apt-get install vim # Just kidding!
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
$ echo $?
100

Quando eu joguei com o chef, usei isso:

# Usage:
# Chef::Provider::Package::Apt.send(:include, CustomApt::UseSudo)

module CustomApt
  module UseSudo
    def self.included(base)
      base.class_eval do

        alias_method :install_package_without_sudo, :install_package
        def install_package(name, version)
          package_name = "#{name}=#{version}"
          package_name = name if @is_virtual_package
          run_command_with_systems_locale(
            :command => "sudo apt-get -q -y#{expand_options(@new_resource.options)} install #{package_name}",
            :environment => {
              "DEBIAN_FRONTEND" => "noninteractive"
            }
            )
        end
      end
    end
  end
end

Eu incluí isso nas minhas receitas, por exemplo, install_packages.rb :

# So we install packages with sudo
Chef::Provider::Package::Apt.send(:include, CustomApt::UseSudo)

include_recipe "imagemagick::devel"

node['application']['install_packages'].each do |package_name|
  package package_name do
    action :install
  end
end
    
por 25.02.2013 / 09:11