Closed milky-milk closed 8 years ago
I tried to add some debug to gem:
def serverspec_commands
if config[:remote_exec]
if config[:serverspec_command]
<<-INSTALL
#{config[:serverspec_command]}
INSTALL
else
<<-INSTALL
whoami
echo $PATH
if [ -d #{config[:default_path]} ]; then
cd #{config[:default_path]}
#{rspec_commands}
#{remove_default_path}
else
echo "ERROR: Default path '#{config[:default_path]}' does not exist"
exit 1
fi
INSTALL
end
and got the output:
D [SSH] kitchen@localhost<{:user_known_hosts_file=>"/dev/null", :paranoid=>false, :port=>32810, :compression=>true, :compression_level=>6, :keepalive=>true, :keepalive_interval=>60, :timeout=>15, :keys_only=>true, :keys=>["/tmp/ansible/base-project/.kitchen/docker_id_rsa"], :auth_methods=>["publickey"], :password=>"kitchen"}> ( whoami
# source $HOME/.rvm/scripts/rvm
echo $PATH
if [ -d /tmp/kitchen ]; then
cd /tmp/kitchen
rspec -c -f documentation --default-path /tmp/kitchen -P roles/common/spec/common_spec.rb
else
echo "ERROR: Default path '/tmp/kitchen' does not exist"
exit 1
fi
)
D [SSH] opening connection to kitchen@localhost<{:user_known_hosts_file=>"/dev/null", :paranoid=>false, :port=>32810, :compression=>true, :compression_level=>6, :keepalive=>true, :keepalive_interval=>60, :timeout=>15, :keys_only=>true, :keys=>["/tmp/ansible/base-project/.kitchen/docker_id_rsa"], :auth_methods=>["publickey"], :password=>"kitchen"}>
kitchen
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
bash: line 6: rspec: command not found
D Cleaning up local sandbox in /tmp/Common-ubuntu-1404-sandbox-20160331-10489-1utyylz
It seems that verifier ignoring user's $PATH
?
When I tried to add source $HOME/.rvm/scripts/rvm
to gem:
def serverspec_commands
if config[:remote_exec]
if config[:serverspec_command]
<<-INSTALL
#{config[:serverspec_command]}
INSTALL
else
<<-INSTALL
whoami
source $HOME/.rvm/scripts/rvm
echo $PATH
if [ -d #{config[:default_path]} ]; then
cd #{config[:default_path]}
#{rspec_commands}
#{remove_default_path}
else
echo "ERROR: Default path '#{config[:default_path]}' does not exist"
exit 1
fi
INSTALL
end
kitchen verify
works fine.
yes i have not got it working with different flavours of rubylike rvm yet. thanks for pointing this out. next thing to fix. -)
you can set the serverspec_command parameter to have the command plus the extra command in front source $HOME/.rvm/scripts/rvm you can set Multiple lines, a.k.a embed shell script like the custom_install_command option. I suggest we add 2 parameters for rvm require_rvm true/false default false and rvm_command defaults to source $HOME/.rvm/scripts/rvm
the other thing you can do is run the serverspec locally on your workstation. remote_exec: false then configure to run on the docker image. then you dn't need al the rvm stuff as ruby will be on your workstation.
you can set the serverspec_command parameter to have the command plus the extra command in front source $HOME/.rvm/scripts/rvm
Thanks! It works.
I suggest we add 2 parameters for rvm require_rvm true/false default false and rvm_command defaults to source $HOME/.rvm/scripts/rvm
It would be great.
probably a more generic solution is to add a parameter additional_serverspec_command that runs in addition to the commands
added additional install and serverspec command options in version 0.4.0 closing
Hello!
I'm trying to use custom Ubuntu and Debian Docker images with installed rvm (ruby 2.3) for kitchen user :
When I'm trying to run
kitchen verify
it fails: http://upaste.me/32cc24597e5f5086aHowever, rspec is installed and exist: http://upaste.me/d86824598be0de65c And I can run test manually:
It seems like verifier don't use user's
$PATH
or ignoring~/.bashrc
settings? I've tried to userspec_path
setting inkitchen.yml
butkitchen verify
fails with error:/usr/bin/env: ruby_executable_hooks: No such file or directory
There is the full output: http://upaste.me/8217245999e0fd72eMy
kitchen.yml
http://upaste.me/db0d246015ada65c2What is intresting: same setup with CentOS-6.7 and rvm in Docker works fine when I run
kitchen verify
.Cant you please tell me where I am wrong? Is it possible to use serverspec verifier with rvm?