Repository: test-kitchen/test-kitchen

Issue #343: Need to fix .kitchen.local.yml behavior
Created: 2014-01-30T21:49:10Z
Hi.
We're currently experiencing a problem with .kitchen.yml.... and having a debate over what should ship in a cookbook.
In a perfect world, we could ship something like this with a cookbook:
https://github.com/opscode-cookbooks/yum/blob/kitchen.yml/.kitchen.yml
And have SeansLaptop-ci keep a ~/.kitchen.local.yml like this:
https://gist.github.com/someara/638102797637385a9432
As it stands right now, it's reading the cookbook local ~.kitchen.local.yml ...
https://gist.github.com/someara/076e0b3c9c5c2bdfcc6f
... instead of what I would expect to see:
https://gist.github.com/someara/3b4dd29bcf3555abc262

Duplicate issue #345: support for command-line option to select driver (fast local TDD vs. remote ci testing)
Created: 2014-02-03T22:09:30Z
I'd like to add a feature request to support a command-line option to allow selection of driver_plugin within .kitchen.yml via erb.
While presently enabling / disabling driver_plugin and driver_configs based on environment variables, it would be nice to support command-line arguments as well. This isn't currently possible because of the way additional arguments are interpreted as a platform selection regex string.
The below works in erb, but obviously fails since the additional argv isn't handled by test-kitchen...
  #--------------------------------------------------------------------------
  # additional erb code to drive selection of test-kitchen's driver_plugin
  # the plugin can be overridden with one of the following
  #   - command-line argument (--kitchen_driver=ec2)
  #   - environment variable (export KITCHEN_DRIVER=docker)
  # if neither are specified, defaults are used...
  #   - kitchen_driver_ci if environment variable CI=true or TRAVIS=true are present
  #   - kitchen_driver_local is used otherwise
  #
  # NOTES:
  #   - command-line option will override environment variable
  #   - kitchen_driver is used in erb scripting in place of driver_plugin
  #--------------------------------------------------------------------------

  kitchen_driver_valid = 'ec2|vagrant|docker'
  kitchen_driver_ci = 'ec2'
  kitchen_driver_local = 'vagrant'
  kitchen_driver_default = kitchen_driver_local

  # process command-line arguments
  ARGV.each do |a|
    arg_key, arg_val = a.split("=")
    if arg_key == "--kitchen_driver" && arg_val
      kitchen_driver_commandline = arg_val
    end
  end

  if defined? kitchen_driver_commandline
    kitchen_driver = kitchen_driver_commandline
    kitchen_driver_selection = "command-line option --kitchen_driver=#{kitchen_driver}"
  elsif ENV['KITCHEN_DRIVER']
    kitchen_driver = ENV['KITCHEN_DRIVER']
    kitchen_driver_selection = "environment varaible KITCHEN_DRIVER=#{kitchen_driver}"
  elsif ENV['CI']=="true"
    kitchen_driver = kitchen_driver_ci
    kitchen_driver_selection = "environment varaible CI=true"
  elsif ENV['TRAVIS']=="true"
    kitchen_driver = kitchen_driver_ci
    kitchen_driver_selection = "environment variable TRAVIS=true"
  else
    kitchen_driver = kitchen_driver_default
    kitchen_driver_selection = "using default kitchen_driver_local=#{kitchen_driver}"
  end

  kitchen_driver_selection = "-----> driver_plugin: " + kitchen_driver_selection + ", driver_plugin: #{kitchen_driver.to_s}"
  puts kitchen_driver_selection

%>

...

driver_plugin: <%= kitchen_driver %>
driver_config:
  <% if kitchen_driver == 'ec2' %>
  aws_access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %>
  aws_secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %>
  aws_ssh_key_id: test-kitchen
  ssh_key: ./kitchen-ec2/test-kitchen.pem
  region: us-east-1
  availability_zone: us-east-1c
  flavor_id: "m1.large"
  groups: ["test-kitchen"]
  <% end %>
  require_chef_omnibus: true

platforms:
- name: ubuntu-12.04
  driver_config:
    <% if kitchen_driver == 'ec2' %>
    image_id: ami-xxxxxxx
    username: ubuntu
    tags: { "Name": "Test Kitchen" }
    <% end %>

Closing comment (2014-02-04T04:23:05Z): So this is actually a dupe of #343