neillturner / kitchen-ansible

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

Failure when using busser_bin #311

Closed e-moshaya closed 5 years ago

e-moshaya commented 5 years ago

I've just implemented https://github.com/MindPointGroup/RHEL7-CIS in all our base images.

One of the cis rule I've applied is "Ensure noexec option set on /tmp partition" However, this has broken running busser tests from /tmp directory with the following error:

-----> Starting Kitchen (v2.3.3)
-----> Verifying <default-amzn-linux-base-image>...
       Preparing files for transfer
-----> Busser installation detected (busser)
-----> Installing Busser plugin: busser-serverspec
       sudo: unable to execute /tmp/verifier/bin/busser: Permission denied

I've tried to pre-install busser to a known path and update .kitchen.yml to:

verifier:
  name: busser
  ruby_bindir: /usr/bin
  busser_bin: /usr/local/bin/busser
  sudo_path: true

However, this also produces the following error:

-----> Starting Kitchen (v2.3.3)
-----> Verifying <default-amzn-linux-base-image>...
       Preparing files for transfer
-----> Busser installation detected (busser)
-----> Installing Busser plugin: busser-serverspec
       Traceback (most recent call last):
        12: from /usr/local/bin/busser:23:in <main>
        11: from /usr/local/bin/busser:23:in load
        10: from /tmp/verifier/gems/gems/busser-0.7.1/bin/busser:8:in <top (required)>'
         9: from /tmp/verifier/gems/gems/thor-0.19.0/lib/thor/base.rb:439:in start'
         8: from /tmp/verifier/gems/gems/thor-0.19.0/lib/thor/shell.rb:17:in shell'
         7: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in require'
         6: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in require'
         5: from /tmp/verifier/gems/gems/thor-0.19.0/lib/thor/shell/color.rb:1:in <top (required)>'
         4: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in require'
         3: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in require'
         2: from /tmp/verifier/gems/gems/thor-0.19.0/lib/thor/shell/basic.rb:2:in <top (required)>'
         1: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in require'
       /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in require': cannot load such file -- io/console (LoadError)

Here's the debug output:

-----> Starting Kitchen (v2.3.3)
-----> Verifying <default-amzn-linux-base-image>...
       Preparing files for transfer
D      Creating local sandbox in /var/folders/2b/1__l5btd66ldxhhtvp1fp6h80000gp/T/default-amzn-linux-base-image-sandbox-20191028-65764-y7r4di
D      [SSH] ec2-user@3.8.22.71<{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :keepalive_maxcount=>3, :timeout=>10, :keys_only=>true, :keys=>["/Users/emoshaya/.ssh/test-kitchen.pem"], :auth_methods=>["publickey"], :verify_host_key=>:never}> (sh -c '
TEST_KITCHEN="1"; export TEST_KITCHEN
BUSSER_ROOT="/tmp/verifier"; export BUSSER_ROOT
GEM_HOME="/tmp/verifier/gems"; export GEM_HOME
GEM_PATH="/tmp/verifier/gems"; export GEM_PATH
GEM_CACHE="/tmp/verifier/gems/cache"; export GEM_CACHE
ruby="/usr/bin/ruby"
gem="/usr/bin/gem"
version="busser"
gem_install_args="busser --no-document --no-format-executable -n /tmp/verifier/bin --no-user-install"
busser="/usr/local/bin/busser"
plugins="busser-serverspec"

$gem list --no-versions | grep "^busser" 2>&1 >/dev/null
if test $? -ne 0; then
  echo "-----> Installing Busser ($version)"
  $gem install $gem_install_args
else
  echo "-----> Busser installation detected ($version)"
fi

if test ! -f "$BUSSER_ROOT/bin/busser"; then
  $busser setup
fi

for plugin in $plugins; do
  $gem list --no-versions | grep "^$plugin$" 2>&1 >/dev/null
  if test $? -ne 0; then
    echo "-----> Installing Busser plugin: $plugin"
    $busser plugin install $plugin
  else
    echo "-----> Busser plugin detected: $plugin"
  fi
done
')
D      [SSH] opening connection to ec2-user@3.8.22.71<{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :keepalive_maxcount=>3, :timeout=>10, :keys_only=>true, :keys=>["/Users/emoshaya/.ssh/test-kitchen.pem"], :auth_methods=>["publickey"], :verify_host_key=>:never}>
-----> Busser installation detected (busser)
-----> Installing Busser plugin: busser-serverspec
       Traceback (most recent call last):
        12: from /usr/local/bin/busser:23:in <main>'
        11: from /usr/local/bin/busser:23:in load'
        10: from /tmp/verifier/gems/gems/busser-0.7.1/bin/busser:8:in <top (required)>'
         9: from /tmp/verifier/gems/gems/thor-0.19.0/lib/thor/base.rb:439:in start'
         8: from /tmp/verifier/gems/gems/thor-0.19.0/lib/thor/shell.rb:17:in shell'
         7: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in require'
         6: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in require'
         5: from /tmp/verifier/gems/gems/thor-0.19.0/lib/thor/shell/color.rb:1:in <top (required)>'
         4: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in require'
         3: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in require'
         2: from /tmp/verifier/gems/gems/thor-0.19.0/lib/thor/shell/basic.rb:2:in <top (required)>'
         1: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in require'
       /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in require': cannot load such file -- io/console (LoadError)
D      Cleaning up local sandbox in /var/folders/2b/1__l5btd66ldxhhtvp1fp6h80000gp/T/default-amzn-linux-base-image-sandbox-20191028-65764-y7r4di
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Verify failed on instance <default-amzn-linux-base-image>.  Please see .kitchen/logs/default-amzn-linux-base-image.log for more details
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running kitchen diagnose --all for configuration

D      ------Exception-------
D      Class: Kitchen::ActionFailed
D      Message: 1 actions failed.
>>>>>>     Verify failed on instance <default-amzn-linux-base-image>.  Please see .kitchen/logs/default-amzn-linux-base-image.log for more details
D      ----------------------
D      ------Backtrace-------
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/command.rb:184:in report_errors'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/command.rb:175:in run_action'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/command/action.rb:36:in block in call'
D      /usr/local/Cellar/ruby/2.6.3/lib/ruby/2.6.0/benchmark.rb:293:in measure'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/command/action.rb:34:in call'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/cli.rb:52:in perform'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/cli.rb:198:in block (2 levels) in <class:CLI>'
D      /usr/local/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:27:in run'
D      /usr/local/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in invoke_command'
D      /usr/local/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor.rb:387:in dispatch'
D      /usr/local/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/base.rb:466:in start'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/bin/kitchen:13:in block in <top (required)>'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/errors.rb:171:in with_friendly_errors'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/bin/kitchen:13:in <top (required)>'
D      /usr/local/lib/ruby/gems/2.6.0/bin/kitchen:23:in load'
D      /usr/local/lib/ruby/gems/2.6.0/bin/kitchen:23:in <top (required)>'
D      /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/cli/exec.rb:74:in load'
D      /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/cli/exec.rb:74:in kernel_load'
D      /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/cli/exec.rb:28:in run'
D      /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/cli.rb:465:in exec'
D      /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor/command.rb:27:in run'
D      /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in invoke_command'
D      /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor.rb:387:in dispatch'
D      /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/cli.rb:27:in dispatch'
D      /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor/base.rb:466:in start'
D      /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/cli.rb:18:in start'
D      /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/exe/bundle:30:in block in <top (required)>'
D      /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/friendly_errors.rb:124:in with_friendly_errors'
D      /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/exe/bundle:22:in <top (required)>'
D      /usr/local/opt/ruby/bin/bundle:23:in load'
D      /usr/local/opt/ruby/bin/bundle:23:in <main>'
D      ----End Backtrace-----
D      -Composite Exception--
D      Class: Kitchen::InstanceFailure
D      Message: Verify failed on instance <default-amzn-linux-base-image>.  Please see .kitchen/logs/default-amzn-linux-base-image.log for more details
D      ----------------------
D      ------Backtrace-------
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/verifier/base.rb:80:in rescue in call'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/verifier/base.rb:79:in call'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:459:in block in verify_action'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:552:in synchronize_or_call'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:514:in block in action'
D      /usr/local/Cellar/ruby/2.6.3/lib/ruby/2.6.0/benchmark.rb:293:in measure'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:513:in action'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:451:in verify_action'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:382:in block (2 levels) in transition_to'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/lifecycle_hooks.rb:45:in run_with_hooks'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:381:in block in transition_to'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:380:in each'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:380:in transition_to'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:162:in verify'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/command.rb:198:in public_send'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/command.rb:198:in run_action_in_thread'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/command.rb:169:in block (2 levels) in run_action'
D      ----End Backtrace-----
D      ---Nested Exception---
D      Class: Kitchen::ActionFailed
D      Message: SSH exited (1) for command: [sh -c '
TEST_KITCHEN="1"; export TEST_KITCHEN
BUSSER_ROOT="/tmp/verifier"; export BUSSER_ROOT
GEM_HOME="/tmp/verifier/gems"; export GEM_HOME
GEM_PATH="/tmp/verifier/gems"; export GEM_PATH
GEM_CACHE="/tmp/verifier/gems/cache"; export GEM_CACHE
ruby="/usr/bin/ruby"
gem="/usr/bin/gem"
version="busser"
gem_install_args="busser --no-document --no-format-executable -n /tmp/verifier/bin --no-user-install"
busser="/usr/local/bin/busser"
plugins="busser-serverspec"

$gem list --no-versions | grep "^busser" 2>&1 >/dev/null
if test $? -ne 0; then
  echo "-----> Installing Busser ($version)"
  $gem install $gem_install_args
else
  echo "-----> Busser installation detected ($version)"
fi

if test ! -f "$BUSSER_ROOT/bin/busser"; then
  $busser setup
fi

for plugin in $plugins; do
  $gem list --no-versions | grep "^$plugin$" 2>&1 >/dev/null
  if test $? -ne 0; then
    echo "-----> Installing Busser plugin: $plugin"
    $busser plugin install $plugin
  else
    echo "-----> Busser plugin detected: $plugin"
  fi
done
']
D      ----------------------
D      ------Backtrace-------
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/verifier/base.rb:80:in rescue in call'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/verifier/base.rb:79:in call'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:459:in block in verify_action'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:552:in synchronize_or_call'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:514:in block in action'
D      /usr/local/Cellar/ruby/2.6.3/lib/ruby/2.6.0/benchmark.rb:293:in measure'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:513:in action'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:451:in verify_action'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:382:in block (2 levels) in transition_to'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/lifecycle_hooks.rb:45:in run_with_hooks'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:381:in block in transition_to'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:380:in each'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:380:in transition_to'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:162:in verify'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/command.rb:198:in public_send'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/command.rb:198:in run_action_in_thread'
D      /usr/local/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/command.rb:169:in block (2 levels) in run_action'
D      ----End Backtrace-----
e-moshaya commented 5 years ago

this issue is related here https://github.com/test-kitchen/busser/issues/35.

I fixed it in the end by setting verifier root_path