Инструмент Chef: говорят, что нужно указать версию при установке httpd

3101
shekhar

Код, который я написал

[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]#  

И я выполнил с приведенной ниже команды и получил ошибку, как

[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 

Я тоже видел бревно

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

Пожалуйста, помогите мне, я что-то упустил?

Спасибо.

2
кто-нибудь может мне помочь? shekhar 9 лет назад 0

3 ответа на вопрос

0
aronchick

The most likely issue you're having is that your yum database has not been updated. You have two options:

  1. Update the yum database manually on your machines using:

    sudo yum update –y 
  2. Create a chef recipe (or line in another chef recipe) which updates the yum database before running the rest of your commands. You can do this with the following line:

    execute 'yum update -y' 
0
Cherry

I had same problem. RedHat can not download httpd from repository. You need to configure CentOs-Base repo fot RedHat.

  1. Create a file centos-base.repo with the follwing contents in /etc/yum.repos.d (change the release version of this file, the below snapshot is for release version 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. Download the gpg key for your release of O.S from centos official site http://mirror.centos.org/centos/ and move it to /etc/pki/rpm-gpg/

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

    2.2 $wget http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

Important

Also check you internet connection. From my experience sometime Linux do not "see" network with default settings.

Primary source

Original source here

0
Sameer Kulkarni

удалите пробел, который вы поместили перед h при написании имени пакета. это должно быть «httpd», а не «httpd»

Похожие вопросы