Using Cumulus VX with Test Kitchen


Userlevel 1
Test Kitchen is a popular tool for automating virtual machines with Vagrant and testing tools such as Serverspec. This article shows you how to use Test Kitchen with Cumulus VX to test Chef recipes.
Requirements
Configuring Test Kitchen
Test Kitchen is very simple to configure, but you should be aware of the following caveats:
  • By default, the Chef provisioner for Test Kitchen uses the Chef Omnibus installer to install Chef. The standard installer does not recognize Cumulus Linux and thus fails to install Chef. You need to use Vagrant provisioning to install Chef from the Cumulus Networks APT repository.
  • Cumulus Linux currently provides Chef 11.6 in the Cumulus Networks APT repository. Chef 11.6 does not support Chef Zero ("local" mode), so you must use the Chef Solo provisioner.
A basic Test Kitchen configuration (.kitchen.yml) for use with the Cumulus VX Vagrant image looks like this:
---  driver:    name: vagrant    provisioner:    name: chef_solo    require_chef_omnibus: false    platforms:    - name: cumulus-vx-2.5.3      driver:        box: cumulus-vx-2.5.3        provision: true        vagrantfiles: ['provision-chef.rb']    suites:    - name: default      run_list:        - recipe[example]  
In addition, you must provide the following Vagrant configuration fragment (provision-chef.rb), which is included by Test Kitchen when the virtual machine is provisioned:
Vagrant.configure("2") do |config|    config.vm.provision :shell, inline: "apt-get update && apt-get install chef"  end
You can then create your test cookbook(s) and Serverspec tests as you normally would.
Adding Switch Port Interfaces with Test Kitchen
By default, Vagrant only configures the first network interface (eth0) for its own use. Additional network interfaces, such as the Cumulus Linux switch port interfaces, must be configured from Test Kitchen.
The following example configuration creates a Cumulus VX virtual machine where the interfaces swp1 through swp4 are created and connected to the preconfigured private network:
platforms:    - name: cumulus-vx-2.5.3      driver:        network:          - ["private_network", {virtualbox__intnet: true}] # swp1          - ["private_network", {virtualbox__intnet: true}] # swp2          - ["private_network", {virtualbox__intnet: true}] # swp3          - ["private_network", {virtualbox__intnet: true}] # swp4
You can find further information on configuring private network interfaces in the Cumulus VX user guide.
Example
You can find a complete example of a Test Kitchen configuration in the test-kitchen/ directory of the cumulus-vx-vagrant Github repository.
Related Links

0 replies

Be the first to reply!

Reply