[chef] Why this 'kitchen setup' failed? 'www.chef.io' is reachable from the guest OS.


Chronological Thread 
  • From: Anthony Kong < >
  • To:
  • Subject: [chef] Why this 'kitchen setup' failed? 'www.chef.io' is reachable from the guest OS.
  • Date: Sun, 1 Feb 2015 17:01:11 +1100


Hi all,

I am following the chapter 6 of the book 'Learning Chef' by Mischa Taylor and Seth Vargo.

First I ran this command kitchen init --create-gemfile to create a set of chef files.

Then I modified the .kitchen.yml to contain these lines 

---
driver:
  name: vagrant

provisioner:
  name: chef_solo

platforms:
  - name: centos65
    driver:
      box: learningchef/centos65
      box_url: learningchef/centos65

suites:
  - name: default
    run_list:
    attributes:



After I created the instance, I ran chef setup   and I got these output and error messages:


$ kitchen setup default-centos65
-----> Starting Kitchen (v1.3.1)
-----> Converging <default-centos65>...
       Preparing files for transfer
       Preparing dna.json
       Berksfile, Cheffile, cookbooks/, or metadata.rb not found so Chef will run with effectively no cookbooks. Is this intended?
       Removing non-cookbook files before transfer
       Preparing solo.rb
-----> Installing Chef Omnibus (install only if missing)
         to file /tmp/install.sh
       trying wget...
       Downloading Chef  for el...
         to file /tmp/install.sh.2337/metadata.txt
       trying wget...
       trying curl...
       grep: /tmp/install.sh.2337/stderr: No such file or directory
       trying python...
       Unable to retrieve a valid package!
       Version:

       Please file a Bug Report at https://github.com/opscode/opscode-omnitruck/issues/new
       Alternatively, feel free to open a Support Ticket at https://www.getchef.com/support/tickets
       More Chef support resources can be found at https://www.getchef.com/support

       Please include as many details about the problem as possible i.e., how to reproduce
       the problem (if possible), type of the Operating System and its version, etc.,
       and any other relevant details that might help us with troubleshooting.

       \nDEBUG OUTPUT FOLLOWS:\n\nSTDERR from wget:\n\n--2015-02-01 05:40:12--  https://www.chef.io/chef/metadata?v=&prerelease=false&nightlies=false&p=el&pv=6&m=x86_64
       Resolving www.chef.io... failed: Name or service not known.
       wget: unable to resolve host address “www.chef.io”\n\nSTDERR from python:\n\nTraceback (most recent call last):
         File "<string>", line 1, in <module>
         File "/usr/lib64/python2.6/urllib2.py", line 126, in urlopen
           return _opener.open(url, data, timeout)
         File "/usr/lib64/python2.6/urllib2.py", line 391, in open
           response = self._open(req, data)
         File "/usr/lib64/python2.6/urllib2.py", line 409, in _open
           '_open', req)
         File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
           result = func(*args)
         File "/usr/lib64/python2.6/urllib2.py", line 1198, in https_open
           return self.do_open(httplib.HTTPSConnection, req)
         File "/usr/lib64/python2.6/urllib2.py", line 1165, in do_open
           raise URLError(err)
       urllib2.URLError: <urlopen error [Errno -2] Name or service not known>\n
>>>>>> Converge failed on instance <default-centos65>.
>>>>>> Please see .kitchen/logs/default-centos65.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: SSH exited (1) for command: [sh -c '
# Check whether a command exists - returns 0 if it does, 1 if it does not
exists() {
  if command -v $1 >/dev/null 2>&1
  then
    return 0
  else
    return 1
  fi
}

# do_wget URL FILENAME
do_wget() {
  echo "trying wget..."
  wget -O "$2" "$1" 2>/tmp/stderr
  # check for bad return status
  test $? -ne 0 && return 1
  # check for 404 or empty file
  grep "ERROR 404" /tmp/stderr 2>&1 >/dev/null
  if test $? -eq 0 || test ! -s "$2"; then
    return 1
  fi
  return 0
}

# do_curl URL FILENAME
do_curl() {
  echo "trying curl..."
  curl -L "$1" > "$2"
  # check for bad return status
  [ $? -ne 0 ] && return 1
  # check for bad output or empty file
  grep "The specified key does not exist." "$2" 2>&1 >/dev/null
  if test $? -eq 0 || test ! -s "$2"; then
    return 1
  fi
  return 0
}

# do_fetch URL FILENAME
do_fetch() {
  echo "trying fetch..."
  fetch -o "$2" "$1" 2>/tmp/stderr
  # check for bad return status
  test $? -ne 0 && return 1
  return 0
}

# do_perl URL FILENAME
do_perl() {
  echo "trying perl..."
  perl -e "use LWP::Simple; getprint($ARGV[0]);" "$1" > "$2"
  # check for bad return status
  test $? -ne 0 && return 1
  # check for bad output or empty file
  # grep "The specified key does not exist." "$2" 2>&1 >/dev/null
  # if test $? -eq 0 || test ! -s "$2"; then
  #   unable_to_retrieve_package
  # fi
  return 0
}

# do_python URL FILENAME
do_python() {
  echo "trying python..."
  python -c "import sys,urllib2 ; sys.stdout.write(urllib2.urlopen(sys.argv[1]).read())" "$1" > "$2"
  # check for bad return status
  test $? -ne 0 && return 1
  # check for bad output or empty file
  #grep "The specified key does not exist." "$2" 2>&1 >/dev/null
  #if test $? -eq 0 || test ! -s "$2"; then
  #  unable_to_retrieve_package
  #fi
  return 0
}

# do_download URL FILENAME
do_download() {
  PATH=/opt/local/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  export PATH

  echo "downloading $1"
  echo "  to file $2"

  # we try all of these until we get success.
  # perl, in particular may be present but LWP::Simple may not be installed

  if exists wget; then
    do_wget $1 $2 && return 0
  fi

  if exists curl; then
    do_curl $1 $2 && return 0
  fi

  if exists fetch; then
    do_fetch $1 $2 && return 0
  fi

  if exists perl; then
    do_perl $1 $2 && return 0
  fi

  if exists python; then
    do_python $1 $2 && return 0
  fi

  echo ">>>>>> wget, curl, fetch, perl or python not found on this instance."
  return 16
}

# @param $1 the omnibus root directory
# @param $2 the requested version of omnibus package
# @return 0 if omnibus needs to be installed, non-zero otherwise
should_update_chef() {
  if test ! -d "$1" ; then return 0
  elif test "$2" = "true" ; then return 1
  elif test "$2" = "latest" ; then return 0
  fi

  local version="`$1/bin/chef-solo -v | cut -d " " -f 2`"
  if echo "$version" | grep "^$2" 2>&1 >/dev/null; then
    return 1
  else
    return 0
  fi
}

if should_update_chef "/opt/chef" "true" ; then
  echo "-----> Installing Chef Omnibus (install only if missing)"
  do_download https://www.chef.io/chef/install.sh /tmp/install.sh
  sudo -E sh /tmp/install.sh
else
  echo "-----> Chef Omnibus installation detected (install only if missing)"
fi
']
>>>>>> ----------------------


I have logged into the box and I verified that I am able to ping www.chef.io


$ kitchen login default-centos65
Last login: Sun Feb  1 05:32:28 2015 from 10.0.2.2
Welcome to your Packer-built virtual machine.
~]$ ping www.chef.io
PING chef.io (184.106.28.83) 56(84) bytes of data.
64 bytes from 184.106.28.83: icmp_seq=1 ttl=63 time=541 ms
64 bytes from 184.106.28.83: icmp_seq=2 ttl=63 time=239 ms
64 bytes from 184.106.28.83: icmp_seq=3 ttl=63 time=534 ms
64 bytes from 184.106.28.83: icmp_seq=4 ttl=63 time=288 ms
^C

So what is wrong with the setup?

Cheers, Tony


  • [chef] Why this 'kitchen setup' failed? 'www.chef.io' is reachable from the guest OS., Anthony Kong, 01/31/2015

Archive powered by MHonArc 2.6.16.

§