neillturner / kitchen-ansible

Ansible Provisioner for Test Kitchen
Other
350 stars 134 forks source link

Action fails on Amazon Linux #194

Closed fiunchinho closed 8 years ago

fiunchinho commented 8 years ago

Provisioning with kitchen-ansible and trying to execute serverspec on ec2 using Amazon Linux platform, results in the following error

kitchen verify ansible-amazon
-----> Starting Kitchen (v1.10.2)
-----> Verifying <ansible-amazon>...
       [Serverspec] Verify on instance=#<Kitchen::Instance:0x007f9bab37cac8> with state={:server_id=>"i-8aa66001", :hostname=>"ec2-52-209-171-33.eu-west-1.compute.amazonaws.com", :last_action=>"setup"}
       Environment variable KITCHEN_SERVER_ID value i-8aa66001
       Environment variable KITCHEN_HOSTNAME value ec2-52-209-171-33.eu-west-1.compute.amazonaws.com
       Environment variable KITCHEN_LAST_ACTION value setup
       Installing ruby, bundler and serverspec remotely on server
Fetching: bundler-1.12.5.gem (100%)
       Successfully installed bundler-1.12.5
       1 gem installed
       /usr/local/bin/bundle
       /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- io/console (LoadError)
        from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/local/share/ruby/gems/2.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/shell/basic.rb:2:in `<top (required)>'
        from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/local/share/ruby/gems/2.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/shell/color.rb:1:in `<top (required)>'
        from /usr/local/share/ruby/gems/2.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/shell.rb:17:in `shell'
        from /usr/local/share/ruby/gems/2.0/gems/bundler-1.12.5/lib/bundler/ui/shell.rb:15:in `initialize'
        from /usr/local/share/ruby/gems/2.0/gems/bundler-1.12.5/lib/bundler/cli.rb:13:in `new'
        from /usr/local/share/ruby/gems/2.0/gems/bundler-1.12.5/lib/bundler/cli.rb:13:in `rescue in start'
        from /usr/local/share/ruby/gems/2.0/gems/bundler-1.12.5/lib/bundler/cli.rb:11:in `start'
        from /usr/local/share/ruby/gems/2.0/gems/bundler-1.12.5/exe/bundle:27:in `block in <top (required)>'
        from /usr/local/share/ruby/gems/2.0/gems/bundler-1.12.5/lib/bundler/friendly_errors.rb:98:in `with_friendly_errors'
        from /usr/local/share/ruby/gems/2.0/gems/bundler-1.12.5/exe/bundle:19:in `<top (required)>'
        from /usr/local/bin/bundle:23:in `load'
        from /usr/local/bin/bundle:23:in `<main>'
>>>>>> ------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) == 'false' ]; then
              sudo -E -H gem install  --no-ri --no-rdoc bundler
            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 "
" >> /tmp/kitchen/Gemfile
sudo -E -H echo "gem 'net-ssh','~> 2.9'
" >> /tmp/kitchen/Gemfile
sudo -E -H echo "gem 'io-console', '~> 0.4.2'
" >> /tmp/kitchen/Gemfile
sudo -E -H echo "gem "json"
" >> /tmp/kitchen/Gemfile
sudo -E -H echo "gem "rake"
" >> /tmp/kitchen/Gemfile
sudo -E -H echo "gem "serverspec"" >> /tmp/kitchen/Gemfile

              BUNDLE_CMD=$(which bundle)
              echo $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 ansible-amazon
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

Any ideas?

neillturner commented 8 years ago

this is a issue with the kitchen-verifier-serverspec. can you create it here: https://github.com/neillturner/kitchen-verifier-serverspec

fiunchinho commented 8 years ago

Oh, sorry. I'll do that. I thought the action was from this repo. Thank you!

neillturner commented 8 years ago

basically bundler is trying to install the following: gem 'net-ssh','~> 2.9' gem 'io-console', '~> 0.4.2' gem "json" gem "rake" gem "serverspec

and if failing on install the io-console i suppose. you could try doing a gem install io-console on the ec2 box to see what problem is. you can create you own gemfiles to override the default. the default is gem 'net-ssh','~> 2.9 gem 'serverspec'" >> #{config[:default_path]}/Gemfile
so i guess you are creating a custom gemfile.