Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CentOS 6.x failure #31

Open
pmyjavec opened this issue Oct 13, 2017 · 2 comments
Open

CentOS 6.x failure #31

pmyjavec opened this issue Oct 13, 2017 · 2 comments

Comments

@pmyjavec
Copy link

When testing against CentOS 6 hosts, it seems the rubygems package is not installed which then causes the "verify" step to fail.

To resolve the issue I just logged into the box manually and installed rubygems

See the output:

>>>>>> ------Exception-------                                                        
>>>>>> Class: Kitchen::ActionFailed                                                  
>>>>>> Message: 1 actions failed.                                                    
>>>>>>     Failed to complete #verify action: [SSH exited (1) for command: [                                                                                               
            if [ ! $(which ruby) ]; then                                             
              echo '-----> Installing ruby, will try to determine platform os'       
              if [ -f /etc/centos-release ] || [ -f /etc/redhat-release ] || [ -f /etc/oracle-release ]; then                                                              
                sudo -E -H yum -y install ruby                                       
              else                                                                   
                if [ -f /etc/system-release ] && grep -q 'Amazon Linux' /etc/system-release; then                                                                          
                  sudo -E -H yum -y install ruby                                     
                else                                                                 
                  sudo -E -H apt-get -y install ruby                                 
                fi                                                                   
              fi                                                                     
            fi                                                                       
                        if [ "$(sudo -E -H gem list bundler -i)" = "true" ]; then    
              echo "Bundler already installed"                                       
            else                                                                     
              if [ "$(sudo -E -H gem list bundler -i)" = "false" ]; then             
                sudo -E -H gem install  --no-ri --no-rdoc bundler                    
              else                                                                   
                echo "ERROR: Ruby not installed correctly"                           
                exit 1                                                               
              fi                                                                     
            fi                                                                       

            if [ -d /tmp/kitchen ]; then                                             
                            if [ "$(sudo -E -H gem list serverspec -i)" = "false" ]; then                                                                                  
                        sudo -E -H rm -f /tmp/kitchen/Gemfile                        
          sudo -E -H echo "source 'https://rubygems.org'" >> /tmp/kitchen/Gemfile    
          sudo -E -H echo "gem 'net-ssh','~> 2.9'"  >> /tmp/kitchen/Gemfile          
          sudo -E -H echo "gem 'serverspec'" >> /tmp/kitchen/Gemfile                 

              BUNDLE_CMD=$(which bundle)                                             
              echo "---> BUNDLE_CMD variable is: ${BUNDLE_CMD}"                      
              sudo -E -H  $BUNDLE_CMD install --gemfile=/tmp/kitchen/Gemfile         
            fi                                                                       

                                                                                     
            else                                                                     
              echo "ERROR: Default path '/tmp/kitchen' does not exist"               
              exit 1                                                                 
            fi                                                                       
]] on default-centos-6                                                               
>>>>>> ----------------------                                                        
>>>>>> Please see .kitchen/logs/kitchen.log for more details                         
>>>>>> Also try running `kitchen diagnose --all` for configuration                   
---
# kitchen.yml
driver:
  name: 'vagrant'

provisioner:
  name: 'ansible_playbook'
  hosts: "localhost"
  require_ansible_repo: false
  require_ansible_omnibus: false
  require_ansible_source: false
  require_pip: true
  ansible_version: 'latest'
  ansible_verbose: true
  require_chef_for_busser: false
  require_ruby_for_busser: false
  ignore_paths_from_root: [".git",".idea",".kitchen", ".bin", ".kitchen.yml", ".gems", ".bundle"]

verifier:
  name: 'serverspec'
  default_pattern: true

platforms:
  - name: 'ubuntu-16.04'
  - name: 'centos-7'
  - name: 'centos-6'

suites:
  - name: 'default'
    attributes:
    run_list:
@tolland
Copy link

tolland commented Feb 8, 2018

Yeah, it seems that on CentOS 7 the ruby package depends on rubygems, so installing ruby also installs rubygems, however that's not true in CentOS 6...

# cat /etc/system-release
CentOS Linux release 7.4.1708 (Core)

$ rpm -q --requires ruby | grep rubygems
ruby(rubygems) >= 2.0.14.1


so installing ruby will pull in the gems package...

              if [ -f /etc/centos-release ] || [ -f /etc/redhat-release ] || [ -f /etc/oracle-release ]; then                                                              
                sudo -E -H yum -y install ruby   

However on CentOS 6, this is not the case, and ruby doesn't depend on rubygems;

# rpm -qR ruby
/usr/bin/ruby
libc.so.6()(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libcrypt.so.1()(64bit)
libdl.so.2()(64bit)
libm.so.6()(64bit)
libpthread.so.0()(64bit)
librt.so.1()(64bit)
libruby.so.1.8()(64bit)
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rtld(GNU_HASH)
ruby-libs = 1.8.7.374-5.el6
rpmlib(PayloadIsXz) <= 5.2-1

# cat /etc/system-release
CentOS release 6.9 (Final)

so installing it doesn't get gems in the path. So the script jumps to trying to trying to install bundler with gem and fails;

if [ "$(sudo -E -H gem list bundler -i)" = "true" ]; then

@tolland
Copy link

tolland commented Feb 8, 2018

This fixes it for CentOS, and I've tested it against CentOS7, and fedora-27

diff --git a/lib/kitchen/verifier/serverspec.rb b/lib/kitchen/verifier/serverspec.rb
index 4304d58..0932e73 100644
--- a/lib/kitchen/verifier/serverspec.rb
+++ b/lib/kitchen/verifier/serverspec.rb
@@ -134,7 +134,7 @@ module Kitchen
             if [ ! $(which ruby) ]; then
               echo '-----> Installing ruby, will try to determine platform os'
               if [ -f /etc/centos-release ] || [ -f /etc/redhat-release ] || [ -f /etc/oracle-release ]; then
-                #{sudo_env('yum')} -y install ruby
+                #{sudo_env('yum')} -y install ruby rubygems
               else
                 if [ -f /etc/system-release ] && grep -q 'Amazon Linux' /etc/system-release; then
                   #{sudo_env('yum')} -y install ruby

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants