To get Test Kitchen running for Ansible testing against the official CentOS 7 box under Vagrant, I had to:
- Install kitchen, kitchen-vagrant, kitchen-ansible gems.
- Add a Gemfile to the serverspec to get 'rake' installed, as it isn't part of ruby in the default CentOS package:
source 'https://rubygems.org'
gem 'rake'
- Avoid using leading zeros on file modes in the serverspec be_mode tests (use three digit modes instead).
To reduce run time, I also added a Vagrantfile stub to disable the auto-installation of the VirtualBox guest tools with the vbguest plugin (optional):
Vagrant.configure("2") do |config|
config.vbguest.auto_update = false
end
...And in .kitchen.yml:
driver:
name: vagrant
vagrantfiles:
- test/vagrant-vbguest.rb
Apart from that, this guide works pretty well for the setup.
For multiple test suites, the suite definition must contain a provisioner entry specifying the full path to the playbook from the top level (Ansible) directory; e.g. test/integration/playbook.yml
.
When testing against multiple, different RHEL/CentOS releases, add a provisioner entry to each platform definition, containing an ansible_yum_repo value for the relevant epel-release URL (e.g. https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
). Note that for older EL6 guests, you will need to update the ca-certificates package before it will be able to download the EPEL RPM successfully; this can be done in a shell provisioner within the additional Vagrant file specified in the config.