What is Kitchen? Kitchen provides a test harness to execute infrastructure code on one or more platforms in isolation.

Was test one of my cookbooks which need to have multiple nodes to setup the cloudera cluster. Also to test the automation deployment script (python api).

Setting up using kitchen was really easy. Below is a sample kitchen.yml file.

---
driver_plugin: vagrant

provisioner:
  name: chef_solo
  # You may wish to disable always updating cookbooks in CI or other testing environments.
  # For example:
  #   always_update_cookbooks: <%= !ENV['CI'] %>
  always_update_cookbooks: true
  require_chef_omnibus: "12"

#
# verifier:
#   name: inspec

driver_config:
  require_chef_omnibus: true
  box: grtjn/centos-6.5

platforms:

    - name: cloudera-manager
      run_list:
        - recipe[cdhmgr-chef-setup::pre_config_selinux_update]

      driver_config:
        customize:
          memory: 2048
        network:
          - ['private_network', {ip: '192.168.139.33'}]

    - name: master-node
      run_list:
        - recipe[cdhmgr-chef-setup::pre_config_selinux_update]

      driver_config:
        customize:
          memory: 2048
        network:
          - ['private_network', {ip: '192.168.139.34'}]

    - name: standby-node
      run_list:
        - recipe[cdhmgr-chef-setup::pre_config_selinux_update]

      driver_config:
        customize:
          memory: 2048
        network:
          - ['private_network', {ip: '192.168.139.35'}]


suites:
  - name: cloudera-cluster
    verifier:
      inspec_tests:
        - test/smoke/default
    attributes:
      cdhmgr-chef-setup:
         etc_hosts_entries:
          192.168.139.33:
            hostname: 'cloudera-cluster-cloudera-manager.vagrantup.com'
            aliases:
              - 'cloudera-cluster-cloudera-manager'
            comment: 'Admin 01   - Cloudera Hadoop Node'
          192.168.139.34:
            hostname: 'cloudera-cluster-master-node.vagrantup.com'
            aliases:
              - 'cloudera-cluster-master-node'
            comment: 'Master 01   - Cloudera Hadoop Node'
          192.168.139.35:
            hostname: 'cloudera-cluster-standby-node.vagrantup.com'
            aliases:
              - 'cloudera-cluster-standby-node'
            comment: 'Standby Node   - Cloudera Hadoop Node'

In the above config

- name: standby-node
  run_list:
    - recipe[cdhmgr-chef-setup::pre_config_selinux_update]

  driver_config:
    customize:
      memory: 2048
    network:
      - ['private_network', {ip: '192.168.139.35'}]

We need to add the above node config in the platform section. The interface IP address ['private_network', {ip: '192.168.139.35'}] needs to match the VirtualBox Host-Only Ethernet Adapter config on VirtualBox.

Here is the output.

ahmed@workhorse-node MINGW64 ~/Documents/WORK/PERSONAL/GITHUB_PROJECTS/cdhmgr-chef-setup (dev)
$ kitchen list
Instance                           Driver   Provisioner  Verifier  Transport  Last Action  Last Error
cloudera-cluster-cloudera-manager  Vagrant  ChefSolo     Busser    Ssh        Converged    <None>
cloudera-cluster-master-node       Vagrant  ChefSolo     Busser    Ssh        Converged    <None>
cloudera-cluster-standby-node      Vagrant  ChefSolo     Busser    Ssh        Converged    <None>

Then we can do below commands to test.

$ kitchen create
$ kitchen converge
$ kitchen setup
$ kitchen verify
$ kitchen destroy