... to add to coderanger, if you want to select drivers or options based on whether your CI tool sets environment variables, you could also do something like this:
---
<%
#--------------------------------------------------------------------------
# the driver_plugin can be overridden with an environment variable:
# $ KITCHEN_DRIVER=docker kitchen test
# if not specified, defaults are used...
# - kitchen_driver_ci if environment variable CI=true or TRAVIS=true are present
# - kitchen_driver_local is used otherwise (which defaults to vagrant)
#--------------------------------------------------------------------------
kitchen_driver_ci = 'ec2'
kitchen_driver_local = 'vagrant'
kitchen_driver_default = kitchen_driver_local
if ENV['KITCHEN_DRIVER']
kitchen_driver = ENV['KITCHEN_DRIVER']
elsif ENV['TRAVIS']=="true"
kitchen_driver = kitchen_driver_ci
elsif ENV['CI']=="true"
kitchen_driver = kitchen_driver_ci
else
kitchen_driver = kitchen_driver_default
end
puts "-----> driver_plugin: #{kitchen_driver.to_s}"
%>
driver_plugin: <%= kitchen_driver %>
driver_config:
require_chef_omnibus: 11.10.4
<% 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: <%= ENV['AWS_SSH_KEY_ID'] || "test-kitchen" %>
ssh_key: <%= ENV['AWS_SSH_KEY_FILE'] || "./test-kitchen.pem" %>
region: <%= ENV['AWS_REGION'] || "us-east-1" %>
availability_zone: <%= ENV['AWS_AVAILABILITY_ZONE'] || "us-east-1c" %>
flavor_id: "t2.small"
groups: ["test-kitchen"]
<% end %>
<% if kitchen_driver == 'vagrant' %>
customize:
memory: 2048
<% end %>
platforms:
- name: ubuntu-14.04
<% if kitchen_driver == 'ec2' %>
driver_config:
image_id: ami-6ab2a702
username: ubuntu
tags: { "Name": "Test Kitchen" }
<% end %>
busser:
sudo: true
suites:
- name: default
run_list: [
]
attributes: {
}
This way you maintain a single file and avoid divergent platform tests (making a change in one file and forgetting to in another). There are also cases where options provided in .kitchen.local.yml might conflict with those in .kitchen.yml.