There are a few basic ways of dynamically configuring Kitchen:
.kitchen.local.ymlwhich could be used for development purposes. This is a file that is not typically checked into version control.
$HOME/.kitchen/config.ymlto set preferred defaults for all your projects.
$HOME/.kitchen/config.ymlfile. This can be useful if you wish to use Kitchen with a continuous integration (CI) system.
To specify a path to a global
config.yml, project or local
.kitchen.yml file, set the following environment variables:
export KITCHEN_GLOBAL_YAML=/path/to/your/global/config.yml export KITCHEN_YAML=/path/to/your/project/.kitchen.yml export KITCHEN_LOCAL_YAML=/path/to/your/local/.kitchen.local.yml
$HOME/.kitchen/config.yml is present, kitchen will merge this file with your project's
.kitchen.local.yml file. Merge precedence is:
For example, one could modify
$HOME/.kitchen/config.yml) to look like:
--- driver: name: openstack openstack_username: <%= ENV['YOUR_OPENSTACK_USERNAME'] %> openstack_api_key: <%= ENV['YOUR_OPENSTACK_API_KEY'] %> openstack_auth_url: <%= ENV['YOUR_OPENSTACK_AUTH_URL'] %> image_ref: <%= ENV['SERVER_IMAGE_ID'] %> flavor_ref: <%= ENV['SERVER_FLAVOR_ID'] %>
Keep in mind, this assumes you have an OpenStack deployment setup and ready to use. This is only an example so to illustrate using environment variables via ERB snippets in the configuration file.
Another handy use of the ERB fragments is to dynamically override the log_level of the provisioner. Since Kitchen 1.7.0 the log level for the provisioner is now independent of the Kitchen log level. Using the following snippet, allows the environment to override the provisioner log level without modifying the config file.:
--- provisioner: name: chef_zero log_level: <%= ENV['CHEF_LOG_LEVEL'] || "auto" %>