# Chef-provisioning and test kitchen

**URL:** <https://discourse.chef.io/t/chef-provisioning-and-test-kitchen/12498>\
**Category:** Chef Infra (archive)\
**Created:** [January 29, 2018, 3:58pm UTC](https://discourse.chef.io/t/chef-provisioning-and-test-kitchen/12498 "2018-01-29T15:58:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mortee](https://avatars.discourse-cdn.com/v4/letter/m/50afbb/32.png) [@mortee](https://discourse.chef.io/u/mortee)\
**Post date:** [January 29, 2018, 3:58pm UTC](https://discourse.chef.io/t/chef-provisioning-and-test-kitchen/12498/1 "2018-01-29T15:58:27Z")

</div>

Is it possible to use the _chef-provisioning_ resources from test kitchen, from inside a regular recipe?

We’ve created a cookbook which currently lets us create various nodes defined in suites in .kitchen.yml. For one of the nodes, we need to run a registration command on another, previously instantiated node. We do it by using the _kitchen-nodes_ provisioner, searching for the target node from whithin the recipe, and use ssh to access it and run the command.

However, I think it’d be much more elegant to have chef itself run the command on the target node, and prevent cross-ssh altogether. So, I’m looking into _chef-provisioning_ and the `machine` and `machine_execute` resources it provides. But I’m kind of stuck at this point - if I simply depend on the gem in metadata.rb, and use those resources in my recipe, I get “`cannot load such file -- chef/provisioning`” (the gem is installed on my workstation). And also, I barely can find any examples clarifying how to use this whole thing.

I’m relatively new to chef, so maybe I’m on completely wrong track with my approach.

---

<div class="post-metadata">

**Author:** ![cheeseplus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/cheeseplus/32/960_2.png) [@cheeseplus](https://discourse.chef.io/u/cheeseplus)\
**Post date:** [January 29, 2018, 10:26pm UTC](https://discourse.chef.io/t/chef-provisioning-and-test-kitchen/12498/2 "2018-01-29T22:26:48Z")

</div>

Possible, yes. Recommend, almost certainly not.

Kitchen doesn’t inherently support multiple nodes at this time though it’s the defining feature of the 2.0 roadmap and we have an RFC [here](https://github.com/chef/chef-rfc/blob/master/rfc084-test-kitchen-multi.md). That said, anything you try to do along those lines will be brittle and bespoke. On top of that, chef-provisioning has it’s own complicated history and most definitely isn’t going to be easy to run inside of kitchen - at that point it’s turtles all the way down and you’ve created something unnecessarily complex/painful.

While it might be possible with enough familiarity to run provisioning from kitchen it’s very much not a supported use case and I’d discourage you as strenuously as possible not to pursue that path. Using recipes that require coordination with other nodes/recipes is also somewhat of an anti-pattern in the Chef world because of the nature of convergent systems frameworks so any approach here will be tricky at best, miserable at worst.

/cheeseplus

---

<div class="post-metadata">

**Author:** ![mortee](https://avatars.discourse-cdn.com/v4/letter/m/50afbb/32.png) [@mortee](https://discourse.chef.io/u/mortee)\
**Post date:** [January 30, 2018, 11:56am UTC](https://discourse.chef.io/t/chef-provisioning-and-test-kitchen/12498/4 "2018-01-30T11:56:29Z")

</div>

Well, I more or less understand. That said, what’s a better approach to develop/test a cookbook which defines several, interoperating nodes, installation of some of which requires running some commands on another node?

---

<div class="post-metadata">

**Author:** ![MattRay](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/mattray/32/47_2.png) [@MattRay](https://discourse.chef.io/u/MattRay)\
**Post date:** [January 30, 2018, 8:27pm UTC](https://discourse.chef.io/t/chef-provisioning-and-test-kitchen/12498/5 "2018-01-30T20:27:50Z")

</div>

You might want to take a look at Kitchen Terraform. I haven’t used it  
personally but I was working with a customer who said they’d been using it  
for awhile and gave it high marks.  
[https://newcontext-oss.github.io/kitchen-terraform/](https://newcontext-oss.github.io/kitchen-terraform/)

Thanks,  
Matt Ray  
Regional Manager, Solutions Architect - APJ :: Chef  
[matt@chef.io](mailto:matt@chef.io)  
AUS: +61 457 231 372  
US: +1 512 731 2218  
mattray :: GitHub :: IRC :: Slack :: Twitter
