# Bootstrap a node through chefserver API in ruby file

**URL:** <https://discourse.chef.io/t/bootstrap-a-node-through-chefserver-api-in-ruby-file/3674>\
**Category:** Chef Infra (archive)\
**Created:** [February 26, 2013, 10:26am UTC](https://discourse.chef.io/t/bootstrap-a-node-through-chefserver-api-in-ruby-file/3674 "2013-02-26T10:26:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ganesan\_A](https://avatars.discourse-cdn.com/v4/letter/g/f07891/32.png) [@Ganesan\_A](https://discourse.chef.io/u/Ganesan_A)\
**Post date:** [February 26, 2013, 10:26am UTC](https://discourse.chef.io/t/bootstrap-a-node-through-chefserver-api-in-ruby-file/3674/1 "2013-02-26T10:26:38Z")

</div>

hi,  
how to bootstrap a node in AWS,hp or openstack using chefserver API without  
workstation it means not using knife command…i have to create a node in any  
provider and register with chefserver [through API only] in ruby …if it is  
possible means pls post any sample code or any idea

Thanks and Regards,  
Ganesan.A

---

<div class="post-metadata">

**Author:** ![Pete\_Cheslock](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/pete_cheslock/32/326_2.png) [@Pete\_Cheslock](https://discourse.chef.io/u/Pete_Cheslock)\
**Post date:** [February 26, 2013, 1:16pm UTC](https://discourse.chef.io/t/bootstrap-a-node-through-chefserver-api-in-ruby-file/3674/2 "2013-02-26T13:16:30Z")

</div>

You could use the fog gem to provision an instance, but when the instance is available (via ssh), you'd have to have something run the bootstrap command to tell the node to provision with chef.

On Feb 26, 2013, at 5:26 AM, [ganesan15785@gmail.com](mailto:ganesan15785@gmail.com) wrote:

> hi,  
> how to bootstrap a node in AWS,hp or openstack using chefserver API without  
> workstation it means not using knife command.....i have to create a node in any  
> provider and register with chefserver [through API only] in ruby ...if it is  
> possible means pls post any sample code or any idea
> 
> Thanks and Regards,  
> Ganesan.A

---

<div class="post-metadata">

**Author:** ![millisami\_r](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/millisami_r/32/418_2.png) [@millisami\_r](https://discourse.chef.io/u/millisami_r)\
**Post date:** [February 26, 2013, 3:41pm UTC](https://discourse.chef.io/t/bootstrap-a-node-through-chefserver-api-in-ruby-file/3674/3 "2013-02-26T15:41:09Z")

</div>

This gem might help you out for what you're asking for:

> **[GitHub - berkshelf/ridley: A reliable Chef API client with a clean syntax](https://github.com/berkshelf/ridley#bootstrapping-nodes)**
>
> A reliable Chef API client with a clean syntax. Contribute to berkshelf/ridley development by creating an account on GitHub.

* * *

@millisami  
~ Sachin Sagar Rai  
Ruby on Rails Developer  
[http://tfm.com.np](http://tfm.com.np)  
[http://nepalonrails.com](http://nepalonrails.com) ([http://nepalonrails.tumblr.com](http://nepalonrails.tumblr.com))  
[http://funsole.com](http://funsole.com)  
Sent with Sparrow ([http://www.sparrowmailapp.com/?sig](http://www.sparrowmailapp.com/?sig))

On Tuesday, February 26, 2013 at 7:01 PM, Pete Cheslock wrote:

> You could use the fog gem to provision an instance, but when the instance is available (via ssh), you'd have to have something run the bootstrap command to tell the node to provision with chef.
> 
> On Feb 26, 2013, at 5:26 AM, \<[ganesan15785@gmail.com](mailto:ganesan15785@gmail.com) ([mailto:ganesan15785@gmail.com](mailto:ganesan15785@gmail.com))\> wrote:
> 
> > hi,  
> > how to bootstrap a node in AWS,hp or openstack using chefserver API without  
> > workstation it means not using knife command.....i have to create a node in any  
> > provider and register with chefserver [through API only] in ruby ...if it is  
> > possible means pls post any sample code or any idea
> > 
> > Thanks and Regards,  
> > Ganesan.A

---

<div class="post-metadata">

**Author:** ![kallistec](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kallistec/32/23_2.png) [@kallistec](https://discourse.chef.io/u/kallistec)\
**Post date:** [February 26, 2013, 4:12pm UTC](https://discourse.chef.io/t/bootstrap-a-node-through-chefserver-api-in-ruby-file/3674/4 "2013-02-26T16:12:00Z")

</div>

This is a work-in-progress project I have to rewrite the bootstrapping process for knife. The code should be a good reference:

> **[GitHub - chef-boneyard/bootstrapper: Improved Bootstrap for Chef/Knife](https://github.com/chef-boneyard/bootstrapper)**
>
> Improved Bootstrap for Chef/Knife. Contribute to chef-boneyard/bootstrapper development by creating an account on GitHub.

--  
Daniel DeLeo

On Tuesday, February 26, 2013 at 7:41 AM, Sachin Sagar Rai wrote:

> This gem might help you out for what you're asking for:
> 
> [GitHub - berkshelf/ridley: A reliable Chef API client with a clean syntax](https://github.com/reset/ridley#bootstrapping-nodes)
> 
> * * *
> 
> @millisami  
> ~ Sachin Sagar Rai  
> Ruby on Rails Developer  
> [http://tfm.com.np](http://tfm.com.np)  
> [http://nepalonrails.com](http://nepalonrails.com) ([http://nepalonrails.tumblr.com](http://nepalonrails.tumblr.com))  
> [http://funsole.com](http://funsole.com)  
> Sent with Sparrow ([http://www.sparrowmailapp.com/?sig](http://www.sparrowmailapp.com/?sig))
> 
> On Tuesday, February 26, 2013 at 7:01 PM, Pete Cheslock wrote:
> 
> > You could use the fog gem to provision an instance, but when the instance is available (via ssh), you'd have to have something run the bootstrap command to tell the node to provision with chef.
> > 
> > On Feb 26, 2013, at 5:26 AM, \<[ganesan15785@gmail.com](mailto:ganesan15785@gmail.com) ([mailto:ganesan15785@gmail.com](mailto:ganesan15785@gmail.com))\> wrote:
> > 
> > > hi,  
> > > how to bootstrap a node in AWS,hp or openstack using chefserver API without  
> > > workstation it means not using knife command.....i have to create a node in any  
> > > provider and register with chefserver [through API only] in ruby ...if it is  
> > > possible means pls post any sample code or any idea
> > > 
> > > Thanks and Regards,  
> > > Ganesan.A

---

<div class="post-metadata">

**Author:** ![Sam\_Pointer](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@Sam\_Pointer](https://discourse.chef.io/u/Sam_Pointer)\
**Post date:** [February 26, 2013, 6:57pm UTC](https://discourse.chef.io/t/bootstrap-a-node-through-chefserver-api-in-ruby-file/3674/5 "2013-02-26T18:57:00Z")

</div>

This is what we do at EA, more-or-less. We poke the API of the cloud in  
question to do some peripheral configuration (security groups, EIP, etc.),  
poke the API to create a box, spin until the box is up, spin again until  
the IP assignment is all done, and then bootstrap the box via ssh.

We do all of this from within an asynchronous job in Rails, in pure ruby  
(no shell-out) by re-using the classes the chef and knife gems provide,  
alongside some custom stuff to talk to RightScale.

So, to give you an answer: you need to get inside the knife and Chef code,  
understand how they do what they do, and then re-use their classes as  
appropriate in your own code. Chef:🔪:Bootstrap in  
./lib/chef/knife/bootstrap.rb (in your exploded gem) might be a good place  
to start. In simple terms, you need an appropriately populated Chef::Config  
and then you need to do something like:

bootstrap = Chef:🔪:Bootstrap.new  
...  
bootstrap.run

S.

On Tue, Feb 26, 2013 at 1:16 PM, Pete Cheslock [petecheslock@gmail.com](mailto:petecheslock@gmail.com)wrote:

> You could use the fog gem to provision an instance, but when the instance  
> is available (via ssh), you'd have to have something run the bootstrap  
> command to tell the node to provision with chef.
> 
> On Feb 26, 2013, at 5:26 AM, [ganesan15785@gmail.com](mailto:ganesan15785@gmail.com) wrote:
> 
> > hi,  
> > how to bootstrap a node in AWS,hp or openstack using chefserver API  
> > without  
> > workstation it means not using knife command.....i have to create a node  
> > in any  
> > provider and register with chefserver [through API only] in ruby ...if  
> > it is  
> > possible means pls post any sample code or any idea
> > 
> > Thanks and Regards,  
> > Ganesan.A
