2

I have a Vagrantfile in which I am provisioning different Vm's by looping through a json file. eg.

cluster_config.each do |cluster|
cluster_name   = cluster[0] # name of node
nodes_config = (JSON.parse(File.read("test_data_bags/myapp/_default.json")))['clusters'][cluster_name]['nodes']

nodes_config.each do |node|


  config.vm.define node_name do |nodeconfig|  
       processes = node_values['processes']
       processes.each do |process|
          nodeconfig.vm.provision :chef_solo do |chef|
              chef.data_bags_path = 'test_data_bags'
              chef.run_list = run_list              
              chef.roles_path = "roles"
                "myapp" => {
                  "cluster_name" => cluster_name,
                  "role" => node_role
                },
              }
          end
       end
    end
end

I would like to do the same within kitchen ie. take an array of attributes and foreach array item - run recipe xyz - this is so I can write some tests using test-kitchen , is this possible?

Thanks

MikeW
  • 4,749
  • 9
  • 42
  • 83

1 Answers1

5

There's a few different workarounds to accomplish this, but they are all definitely workarounds. There is an issue that was opened to discuss support of multiple boxes on test-kitchen, and you can go there to read more about why this probably won't be supported any time soon. TL;DR: it's not really a goal of the project.

Workarounds include:

  1. Chef-provisioning can bootstrap more servers from a single provisioned server/test-suite
  2. Kitchen-nodes provisioner can share data about each server to the other test-suites in your setup
  3. A custom Vagrantfile template for test-kitchen
Martin
  • 2,815
  • 1
  • 21
  • 30