0
votes

I am new to chef and following "Learning Chef" book from "O'Riely" to learn the chef basics. In its chapter 07 they have described to install httpd service on chef client(node) from chef host using cookbook.

This is how my .kitchen.yaml file looks like :

 ---
driver:
  name: vagrant

provisioner:
  name: chef_zero

platforms:
  - name: centos_apache
    driver:
     box: learningchef/centos65
     boxurl: learningchef/centos65

suites:
  - name: default
    run_list:
      - recipe[my_apache::default]
    attributes:

The recipe for installing httpd service looks like :

#
# Cookbook Name:: my_apache
# Recipe:: default
#
# Copyright (c) 2015 The Authors, All Rights Reserved.
#

yum_package 'httpd' do
  source "/home/vipul/Downloads/httpd-2.2.15-39.el6.centos.x86_64.rpm"
  action :install
end

And this is the log which I get after executing the command "kitchen converge"

-----> Starting Kitchen (v1.4.0)
-----> Converging <default-centos-apache>...
       Preparing files for transfer
       Preparing dna.json
       Preparing current project directory as a cookbook
       Removing non-cookbook files before transfer
       Preparing validation.pem
       Preparing client.rb
-----> Chef Omnibus installation detected (install only if missing)
       Transferring files to <default-centos-apache>
       Starting Chef Client, version 12.4.0
       [2015-07-08T12:56:06+00:00] WARN: Child with name 'dna.json' found in multiple directories: /tmp/kitchen/dna.json and /tmp/kitchen/dna.json
       resolving cookbooks for run list: ["my_apache::default"]
       Synchronizing Cookbooks:
         - my_apache
       Compiling Cookbooks...
       Converging 1 resources
       Recipe: my_apache::default


           ================================================================================
           Error executing action `install` on resource 'yum_package[httpd]'
           ================================================================================

           Mixlib::ShellOut::ShellCommandFailed
           ------------------------------------
           Expected process to exit with [0], but received '1'
           ---- Begin output of /usr/bin/python /opt/chef/embedded/apps/chef/lib/chef/provider/package/yum-dump.py --options --installed-provides --yum-lock-timeout 30 ----
           STDOUT: [option installonlypkgs] kernel kernel-bigmem installonlypkg(kernel-module) installonlypkg(vm) kernel-enterprise kernel-smp kernel-debug kernel-unsupported kernel-source kernel-devel kernel-PAE kernel-PAE-debug
           Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was
           14: PYCURL ERROR 7 - "Failed to connect to 2a02:2498:1:3d:5054:ff:fed3:e91a: Network is unreachable"
           STDERR: yum-dump Repository Error: Cannot find a valid baseurl for repo: base
           ---- End output of /usr/bin/python /opt/chef/embedded/apps/chef/lib/chef/provider/package/yum-dump.py --options --installed-provides --yum-lock-timeout 30 ----
           Ran /usr/bin/python /opt/chef/embedded/apps/chef/lib/chef/provider/package/yum-dump.py --options --installed-provides --yum-lock-timeout 30 returned 1

           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cache/cookbooks/my_apache/recipes/default.rb

             8: yum_package 'httpd' do
             9:   source "/home/vipul/Downloads/httpd-2.2.15-39.el6.centos.x86_64.rpm"
            10:   action :install
            11: end

           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cache/cookbooks/my_apache/recipes/default.rb:8:in `from_file'

           yum_package("httpd") do
             action :install
             retries 0
             retry_delay 2
             default_guard_interpreter :default
             package_name "httpd"
             source "/home/vipul/Downloads/httpd-2.2.15-39.el6.centos.x86_64.rpm"
             flush_cache {:before=>false, :after=>false}
             declared_type :yum_package
             cookbook_name "my_apache"
             recipe_name "default"
           end


       Running handlers:
       [2015-07-08T12:56:14+00:00] ERROR: Running exception handlers
       Running handlers complete
       [2015-07-08T12:56:14+00:00] ERROR: Exception handlers complete
       Chef Client failed. 0 resources updated in 11.596431753 seconds
       [2015-07-08T12:56:14+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
       [2015-07-08T12:56:14+00:00] ERROR: yum_package[httpd] (my_apache::default line 8) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
       ---- Begin output of /usr/bin/python /opt/chef/embedded/apps/chef/lib/chef/provider/package/yum-dump.py --options --installed-provides --yum-lock-timeout 30 ----
       STDOUT: [option installonlypkgs] kernel kernel-bigmem installonlypkg(kernel-module) installonlypkg(vm) kernel-enterprise kernel-smp kernel-debug kernel-unsupported kernel-source kernel-devel kernel-PAE kernel-PAE-debug
       Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was
       14: PYCURL ERROR 7 - "Failed to connect to 2a02:2498:1:3d:5054:ff:fed3:e91a: Network is unreachable"
       STDERR: yum-dump Repository Error: Cannot find a valid baseurl for repo: base
       ---- End output of /usr/bin/python /opt/chef/embedded/apps/chef/lib/chef/provider/package/yum-dump.py --options --installed-provides --yum-lock-timeout 30 ----
       Ran /usr/bin/python /opt/chef/embedded/apps/chef/lib/chef/provider/package/yum-dump.py --options --installed-provides --yum-lock-timeout 30 returned 1
       [2015-07-08T12:56:14+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
>>>>>> Converge failed on instance <default-centos-apache>.
>>>>>> Please see .kitchen/logs/default-centos-apache.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: SSH exited (1) for command: [sh -c '

sudo -E /opt/chef/bin/chef-client --local-mode --config /tmp/kitchen/client.rb --log_level auto --force-formatter --no-color --json-attributes /tmp/kitchen/dna.json --chef-zero-port 8889
']
>>>>>> ----------------------

I want to install httpd service using the local rpm package. Chef client is already installed on the virtual machine. I have tried various steps, but getting same output always.


Update: So I did yum update in my host and client both. After that the output log changed.. I says that it couldn't find the package at defined source, while it is present there. Please suggest::

-----> Starting Kitchen (v1.4.0)
-----> Converging <default-centos-apache>...
       Preparing files for transfer
       Preparing dna.json
       Preparing current project directory as a cookbook
       Removing non-cookbook files before transfer
       Preparing validation.pem
       Preparing client.rb
-----> Chef Omnibus installation detected (install only if missing)
       Transferring files to <default-centos-apache>
       Starting Chef Client, version 12.4.0
       [2015-07-09T14:16:57+00:00] WARN: Child with name 'dna.json' found in multiple directories: /tmp/kitchen/dna.json and /tmp/kitchen/dna.json
       resolving cookbooks for run list: ["my_apache::default"]
       Synchronizing Cookbooks:
         - my_apache
       Compiling Cookbooks...
       Converging 1 resources
       Recipe: my_apache::default


           ================================================================================
           Error executing action `install` on resource 'yum_package[httpd]'
           ================================================================================

           Chef::Exceptions::Package
           -------------------------
           Package httpd not found: /home/vipul/Downloads/httpd-2.2.15-39.el6.centos.x86_64.rpm

           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cache/cookbooks/my_apache/recipes/default.rb

             8: package "httpd" do
             9:   source "/home/vipul/Downloads/httpd-2.2.15-39.el6.centos.x86_64.rpm"
            10:   action :install
            11: end

           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cache/cookbooks/my_apache/recipes/default.rb:8:in `from_file'

           yum_package("httpd") do
             action :install
             retries 0
             retry_delay 2
             default_guard_interpreter :default
             package_name "httpd"
             source "/home/vipul/Downloads/httpd-2.2.15-39.el6.centos.x86_64.rpm"
             flush_cache {:before=>false, :after=>false}
             declared_type :package
             cookbook_name "my_apache"
             recipe_name "default"
           end


       Running handlers:
       [2015-07-09T14:17:01+00:00] ERROR: Running exception handlers
       Running handlers complete
       [2015-07-09T14:17:01+00:00] ERROR: Exception handlers complete
       Chef Client failed. 0 resources updated in 6.822340816 seconds
       [2015-07-09T14:17:01+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
       [2015-07-09T14:17:01+00:00] ERROR: yum_package[httpd] (my_apache::default line 8) had an error: Chef::Exceptions::Package: Package httpd not found: /home/vipul/Downloads/httpd-2.2.15-39.el6.centos.x86_64.rpm
       [2015-07-09T14:17:01+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
>>>>>> Converge failed on instance <default-centos-apache>.
>>>>>> Please see .kitchen/logs/default-centos-apache.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: SSH exited (1) for command: [sh -c '

sudo -E /opt/chef/bin/chef-client --local-mode --config /tmp/kitchen/client.rb --log_level auto --force-formatter --no-color --json-attributes /tmp/kitchen/dna.json --chef-zero-port 8889
']
>>>>>> ----------------------
2
Looks like a networking issue: "Network is unreachable" are you located behind a corporate firewall? - Mark O'Connor
Yes I'm, but after setting terminal proxies, I'm able to successfully execute the command "curl www.google.com". - Vipul
Terminal proxies are not enough. Kitchen is running chef client within a virtual machine. See: docs.chef.io/config_yml_kitchen.html#work-with-proxies - Mark O'Connor
This worked perfectly for me, and I was able to do the apache web server installation, but what to do if the server is completely isolated from internet, no proxies or etc. What steps should we take. - Vipul
Some people use caching proxies, but I have no personal experience using them. - Mark O'Connor

2 Answers

0
votes

Might want to try following the steps outlined here if you can't work out your proxy/network issues. http://xmodulo.com/how-to-fix-yum-errors-on-centos-rhel-or-fedora.html

Regards,

0
votes

The answer to the problem is in comments of question,by Mark. Hence just pasting it here.

Terminal proxies are not enough. Kitchen is running chef client within a virtual machine. See: docs.chef.io/config_yml_kitchen.html#work-with-proxies