neillturner / kitchen-verifier-serverspec

A Test Kitchen Serverspec Verifer without having to transit the Busser layer
Other
39 stars 19 forks source link

Bundler installed as root, can't be found #14

Closed jaxzin closed 8 years ago

jaxzin commented 8 years ago

I think this is related to #5, I'm getting command not found because bundler is installed with sudo when it shouldn't be.

See http://stackoverflow.com/questions/25437817/dont-run-bundler-as-root-what-is-the-exact-difference-made-by-using-root

neillturner commented 8 years ago

I have a very simple install of ruby. Its not designed for a production system just to be able to run serverspec. -)

Because i install ruby under root then i also install bundler under root otherwise i have found I get lots of problems.

its had to cover all the cases. sometimes ruby may already be installed under all root or all sort of different users and we add bundler and a few gems. I think the best idea is to move it to a shell script so that it can be customized more easily. Also ruby installs are a bit of a nightmare to be frank.

Happy to take any improvements. I can make the sudo of bundler an option. but it will take me time to figure out how to make that work. -)

my guess is you already have a ruby installed on your server so it gets confused.

jaxzin commented 8 years ago

I'm using the bento/centos-7.2 box. Does this look wrong for my .kitchen.yml and would cause it not to find bundle?

---
driver:
  name: vagrant

provisioner:
  hosts: test-kitchen
  name: ansible_playbook
  roles_path: roles
  require_ansible_repo: true
  ansible_verbose: true
  ansible_version: latest
  require_ruby_for_busser: true
  require_chef_for_busser: false
#  env_vars:
#    ANSIBLE_KEEP_REMOTE_FILES: 1

transport:
  max_ssh_sessions: 5 # Resolves https://github.com/test-kitchen/test-kitchen/issues/1035

platforms:
  - name: centos-7.2
    driver_plugin: vagrant
    driver_config:
      box: bento/centos-7.2
      network:
      - ['forwarded_port', {guest: 443, host: 20443}]
      - ['private_network', {ip: '192.168.33.11'}]

suites:
  - name: default
    verifier:
      patterns:
      - roles/docker-node/spec/docker-node_spec.rb

verifier:
  name: serverspec

The error I got was:

       Installing ruby, bundler and serverspec remotely on server
Fetching: bundler-1.12.5.gem (100%)
       Successfully installed bundler-1.12.5
       1 gem installed
       which: no bundle in (/usr/local/bin:/usr/bin)

       install: unrecognized option '--gemfile=/tmp/kitchen/Gemfile'
       Try 'install --help' for more information.
jaxzin commented 8 years ago

Now that I got neillturner/ansible_repo working locally, I found my mistake in the above example. I was missing:

suites:
  - name: default
    verifier:
      bundler_path: '/usr/local/bin'
      rspec_path: '/usr/local/bin'
      ...
neillturner commented 8 years ago

thanks for logging this as it will help others