Ferramenta do Chef: dizendo que precisa mencionar a versão durante a instalação do httpd

2

Código que escrevi

[root@ns1 sysadmin]# cat installstarthttpd.rb 
package' httpd'

service 'httpd' do
       action [:start, :enable]
end

file '/var/www/html/index.html' do
       content '        <html>
                       <title>
                       Page from Chef
                       </title>
                       <body>
                       <h1> Welcome Raja</h1>
                       </body>
                       </html>
               '
end

[root@ns1 sysadmin]# 

E eu executei com o comando abaixo e recebi um erro como

[root@ns1 sysadmin]# chef-apply installstarthttpd.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
 * package[ httpd] action install
   * No version specified, and no candidate version available for  httpd
   ================================================================================
   Error executing action 'install' on resource 'package[ httpd]'
   ================================================================================

   Chef::Exceptions::Package
   -------------------------
   No version specified, and no candidate version available for  httpd

   Resource Declaration:
   ---------------------
   # In installstarthttpd.rb

     1: package' httpd'
     2: 

   Compiled Resource:
   ------------------
   # Declared in installstarthttpd.rb:1:in 'run_chef_recipe'

   package(" httpd") do
     action :install
     retries 0
     retry_delay 2
     guard_interpreter :default
     package_name " httpd"
     timeout 900
     cookbook_name "(chef-apply cookbook)"
     recipe_name "(chef-apply recipe)"
   end

[2014-10-14T01:10:18-04:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2014-10-14T01:10:18-04:00] FATAL: Chef::Exceptions::Package: package[ httpd] ((chef-apply cookbook)::(chef-apply recipe) line 1) had an error: Chef::Exceptions::Package: No version specified, and no candidate version available for  httpd

Eu vi o log também

[root@ns1 sysadmin]# cat /var/chef/cache/chef-stacktrace.out 
Generated at 2014-10-14 01:10:18 -0400
Chef::Exceptions::Package: package[ httpd] ((chef-apply cookbook)::(chef-apply recipe) line 1) had an error: Chef::Exceptions::Package: No version specified, and no candidate version available for  httpd
/opt/chefdk/embedded/apps/chef/lib/chef/mixin/why_run.rb:241:in 'run'
/opt/chefdk/embedded/apps/chef/lib/chef/mixin/why_run.rb:322:in 'block in run'
/opt/chefdk/embedded/apps/chef/lib/chef/mixin/why_run.rb:321:in 'each'
/opt/chefdk/embedded/apps/chef/lib/chef/mixin/why_run.rb:321:in 'run'
/opt/chefdk/embedded/apps/chef/lib/chef/provider.rb:135:in 'process_resource_requirements'
/opt/chefdk/embedded/apps/chef/lib/chef/provider.rb:111:in 'run_action'
/opt/chefdk/embedded/apps/chef/lib/chef/resource.rb:648:in 'run_action'
/opt/chefdk/embedded/apps/chef/lib/chef/runner.rb:49:in 'run_action'
/opt/chefdk/embedded/apps/chef/lib/chef/runner.rb:81:in 'block (2 levels) in converge'
/opt/chefdk/embedded/apps/chef/lib/chef/runner.rb:81:in 'each'
/opt/chefdk/embedded/apps/chef/lib/chef/runner.rb:81:in 'block in converge'
/opt/chefdk/embedded/apps/chef/lib/chef/resource_collection.rb:98:in 'block in execute_each_resource'
/opt/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:116:in 'call'
/opt/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:116:in 'call_iterator_block'
/opt/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:85:in 'step'
/opt/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:104:in 'iterate'
/opt/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:55:in 'each_with_index'
/opt/chefdk/embedded/apps/chef/lib/chef/resource_collection.rb:96:in 'execute_each_resource'
/opt/chefdk/embedded/apps/chef/lib/chef/runner.rb:80:in 'converge'
/opt/chefdk/embedded/apps/chef/lib/chef/application/apply.rb:144:in 'run_chef_recipe'
/opt/chefdk/embedded/apps/chef/lib/chef/application/apply.rb:153:in 'run_application'
/opt/chefdk/embedded/apps/chef/lib/chef/application/apply.rb:166:in 'run'
/opt/chefdk/embedded/apps/chef/bin/chef-apply:25:in '<top (required)>'
/usr/bin/chef-apply:34:in 'load'

Por favor me ajude, estou sentindo falta de alguma coisa?

Obrigado.

    
por shekhar 14.10.2014 / 07:31

3 respostas

0

O problema mais provável que você está tendo é que seu banco de dados do yum não foi atualizado. Você tem duas opções:

  1. Atualize o banco de dados do yum manualmente em suas máquinas usando:

    sudo yum update –y
    
  2. Crie uma receita de chef (ou coloque outra receita de chef) que atualize o banco de dados do yum antes de executar o resto dos seus comandos. Você pode fazer isso com a seguinte linha:

    execute 'yum update -y'
    
por 26.11.2014 / 04:18
0

Eu tive o mesmo problema. RedHat não pode baixar httpd do repositório. Você precisa configurar o repo CentOs-Base para RedHat.

  1. Crie um arquivo centos-base.repo com o conteúdo seguinte em /etc/yum.repos.d (altere a versão de lançamento deste arquivo, o instantâneo abaixo é para a versão 6)

yum.repos.d

#####################################################################
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-6 - Base
mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/6/os/$basearch/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-6 - Updates
mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/6/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-6 - Extras
mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/6/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6 - Plus
mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/6/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-6 - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/6/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6


#####################################################################
  1. Faça o download da chave gpg para o seu lançamento do sistema operacional do link do site oficial centos e mova-o para /etc/pki/rpm-gpg/

    2.1 $ cd / etc / pki / rpm-gpg /

    2.2 $ wget link

Importante

Verifique também sua conexão com a internet. Da minha experiência, algum dia o Linux não "vê" a rede com configurações padrão.

Fonte primária

Fonte original aqui

    
por 03.12.2014 / 10:40
0

remova o espaço que você colocou antes de escrever um nome de pacote. deve ser 'httpd' não 'httpd'

    
por 29.02.2016 / 08:39