# Help in how to add nodes to different environments

**URL:** <https://discourse.chef.io/t/help-in-how-to-add-nodes-to-different-environments/5132>\
**Category:** Chef Infra (archive)\
**Created:** [March 17, 2014, 3:13pm UTC](https://discourse.chef.io/t/help-in-how-to-add-nodes-to-different-environments/5132 "2014-03-17T15:13:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Venkat\_Chowdhary](https://avatars.discourse-cdn.com/v4/letter/v/dbc845/32.png) [@Venkat\_Chowdhary](https://discourse.chef.io/u/Venkat_Chowdhary)\
**Post date:** [March 17, 2014, 3:13pm UTC](https://discourse.chef.io/t/help-in-how-to-add-nodes-to-different-environments/5132/1 "2014-03-17T15:13:37Z")

</div>

Hi

I am using chef-solo. I am creating environments (dev.json) manually like below:

{  
“name”: “dev”,  
“description”: “Development Environment”,  
“cookbook\_versions”: {  
},  
“json\_class”: “Chef::Environment”,  
“chef\_type”: “environment”,  
“default\_attributes”: {  
},  
“override\_attributes”: {  
}  
}

Could you please help me how to add nodes to different environments like (dev, staging, production etc …)

Your help is highly appreciable.

Thanks in advance.

Thanks & Regards  
Venkat

---

<div class="post-metadata">

**Author:** ![jeffbyrnes](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/jeffbyrnes/32/1478_2.png) [@jeffbyrnes](https://discourse.chef.io/u/jeffbyrnes)\
**Post date:** [March 17, 2014, 3:20pm UTC](https://discourse.chef.io/t/help-in-how-to-add-nodes-to-different-environments/5132/2 "2014-03-17T15:20:25Z")

</div>

The environment is set when converging the node. With a Chef Server, you’d set it on the initial bootstrap, and it would stick moving forward from there.

With chef-solo, you run the chef-solo command on each particular instance. You’ll need to either specify a config file that provides the values for the particular node you’re bootstrapping, or set the environment directly in the chef-solo command using the environment flag (-E or --environment).

E.g., sudo chef-solo -E prod -N my-new-node -o role[my-new-role]

Might need some quotes in there, but that’s kind of the idea. Others might have more experience in this realm, however.

See the docs on Chef Solo, specifically here: [http://docs.opscode.com/chef\_solo.html#chef-solo-executable](http://docs.opscode.com/chef_solo.html#chef-solo-executable) for full details on the arguments it takes.

## It’d probably be easier to deploy a config file particular to each node as part of your deployment process, and tell Chef Solo to read that config file, instead of specifying things in the command itself. E.g., sudo chef-solo -c ~/chef/solo.rb

Jeff Byrnes  
@berkleebassist  
Operations Engineer  
EverTrue  
704.516.4628

On March 17, 2014 at 11:13:37 AM, Venkat Chowdhary ([nit\_venki2002@yahoo.co.in](mailto:nit_venki2002@yahoo.co.in)) wrote:

Hi

I am using chef-solo. I am creating environments (dev.json) manually like below:

{  
“name”: “dev”,  
“description”: “Development Environment”,  
“cookbook\_versions”: {  
},  
“json\_class”: “Chef::Environment”,  
“chef\_type”: “environment”,  
“default\_attributes”: {  
},  
“override\_attributes”: {  
}  
}

Could you please help me how to add nodes to different environments like (dev, staging, production etc …)

Your help is highly appreciable.

Thanks in advance.

Thanks & Regards  
Venkat

---

<div class="post-metadata">

**Author:** ![Venkat\_Chowdhary](https://avatars.discourse-cdn.com/v4/letter/v/dbc845/32.png) [@Venkat\_Chowdhary](https://discourse.chef.io/u/Venkat_Chowdhary)\
**Post date:** [March 17, 2014, 3:34pm UTC](https://discourse.chef.io/t/help-in-how-to-add-nodes-to-different-environments/5132/3 "2014-03-17T15:34:36Z")

</div>

Thanks Jeff, Your help is highly appreciable.

Yes, its better if we can able to manage it through a config file. I am still searching how to do using config file.

Thanks & Regards  
Venkat

On Monday, 17 March 2014 8:51 PM, Jeff Byrnes [jeff@evertrue.com](mailto:jeff@evertrue.com) wrote:

The environment is set when converging the node. With a Chef Server, you’d set it on the initial bootstrap, and it would stick moving forward from there.

With chef-solo, you run the chef-solo command on each particular instance. You’ll need to either specify a config file that provides the values for the particular node you’re bootstrapping, or set the environment directly in the chef-solo command using the environment flag (-E or --environment).

E.g., sudo chef-solo -E prod -N my-new-node -o role[my-new-role]

Might need some quotes in there, but that’s kind of the idea. Others might have more experience in this realm, however.

See the docs on Chef Solo, specifically here: [http://docs.opscode.com/chef\_solo.html#chef-solo-executable](http://docs.opscode.com/chef_solo.html#chef-solo-executable) for full details on the arguments it takes.

It’d probably be easier to deploy a config file particular to each node as part of your deployment process, and tell Chef Solo to read that config file, instead of specifying things in the command itself. E.g., sudo chef-solo -c ~/chef/solo.rb  
– Jeff Byrnes  
@berkleebassist

Operations Engineer  
EverTrue  
704.516.4628

On March 17, 2014 at 11:13:37 AM, Venkat Chowdhary ([nit\_venki2002@yahoo.co.in](mailto:nit_venki2002@yahoo.co.in)) wrote:  
Hi

I am using chef-solo. I am creating environments  
(dev.json) manually like below:

{  
“name”:  
“dev”,  
“description”:  
“Development Environment”,

“cookbook\_versions”: {  
},  
“json\_class”:  
“Chef::Environment”,  
“chef\_type”:  
“environment”,

“default\_attributes”: {  
},

“override\_attributes”: {  
}  
}

Could you please help me how to add nodes to different  
environments like (dev, staging, production etc …)

Your help is highly appreciable.

Thanks in advance.

Thanks & Regards  
Venkat

---

<div class="post-metadata">

**Author:** ![coderanger](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/coderanger/32/5_2.png) [@coderanger](https://discourse.chef.io/u/coderanger)\
**Post date:** [March 17, 2014, 5:22pm UTC](https://discourse.chef.io/t/help-in-how-to-add-nodes-to-different-environments/5132/4 "2014-03-17T17:22:21Z")

</div>

There is no single config file for this. You use the key "chef\_environment" in each node's JSON data. Environments are mostly moot in chef-solo, nothing they do can't be done in a roughly equivalent way with roles, so its pretty much the same either way.

--Noah

On Mar 17, 2014, at 8:34 AM, Venkat Chowdhary [nit\_venki2002@yahoo.co.in](mailto:nit_venki2002@yahoo.co.in) wrote:

> Thanks Jeff, Your help is highly appreciable.
> 
> Yes, its better if we can able to manage it through a config file. I am still searching how to do using config file.
> 
> Thanks & Regards  
> Venkat
> 
> On Monday, 17 March 2014 8:51 PM, Jeff Byrnes [jeff@evertrue.com](mailto:jeff@evertrue.com) wrote:  
> The environment is set when converging the node. With a Chef Server, you’d set it on the initial bootstrap, and it would stick moving forward from there.
> 
> With chef-solo, you run the chef-solo command on each particular instance. You’ll need to either specify a config file that provides the values for the particular node you’re bootstrapping, or set the environment directly in the chef-solo command using the environment flag (-E or --environment).
> 
> E.g., sudo chef-solo -E prod -N my-new-node -o role[my-new-role]
> 
> Might need some quotes in there, but that’s kind of the idea. Others might have more experience in this realm, however.
> 
> See the docs on Chef Solo, specifically here: [chef-solo](http://docs.opscode.com/chef_solo.html#chef-solo-executable) for full details on the arguments it takes.
> 
> ## It’d probably be easier to deploy a config file particular to each node as part of your deployment process, and tell Chef Solo to read that config file, instead of specifying things in the command itself. E.g., sudo chef-solo -c ~/chef/solo.rb
> 
> Jeff Byrnes  
> @berkleebassist  
> Operations Engineer  
> EverTrue  
> 704.516.4628
> 
> On March 17, 2014 at 11:13:37 AM, Venkat Chowdhary (nit\_venki2002@yahoo.co.in) wrote:  
> Hi
> 
> I am using chef-solo. I am creating environments (dev.json) manually like below:
> 
> {  
> "name": "dev",  
> "description": "Development Environment",  
> "cookbook\_versions": {  
> },  
> "json\_class": "Chef::Environment",  
> "chef\_type": "environment",  
> "default\_attributes": {  
> },  
> "override\_attributes": {  
> }  
> }
> 
> Could you please help me how to add nodes to different environments like (dev, staging, production etc ...)
> 
> Your help is highly appreciable.
> 
> Thanks in advance.
> 
> Thanks & Regards  
> Venkat

---

<div class="post-metadata">

**Author:** ![Venkat\_Chowdhary](https://avatars.discourse-cdn.com/v4/letter/v/dbc845/32.png) [@Venkat\_Chowdhary](https://discourse.chef.io/u/Venkat_Chowdhary)\
**Post date:** [March 18, 2014, 6:06am UTC](https://discourse.chef.io/t/help-in-how-to-add-nodes-to-different-environments/5132/5 "2014-03-18T06:06:25Z")

</div>

Thank you Noah.

For now i will go with key "chef\_environment", if i found any better solution, will let the group know about the same.

Thanks & Regards  
Venkat

On Monday, 17 March 2014 10:53 PM, Noah Kantrowitz [noah@coderanger.net](mailto:noah@coderanger.net) wrote:

There is no single config file for this. You use the key "chef\_environment" in each node's JSON data. Environments are mostly moot in chef-solo, nothing they do can't be done in a roughly equivalent way with roles, so its pretty much the same either way.

--Noah

On Mar 17, 2014, at 8:34 AM, Venkat Chowdhary [nit\_venki2002@yahoo.co.in](mailto:nit_venki2002@yahoo.co.in) wrote:

> Thanks Jeff, Your help is highly appreciable.
> 
> Yes, its better if we can able to manage it through a config file. I am still searching how to do using config file.
> 
> Thanks & Regards  
> Venkat
> 
> On Monday, 17 March 2014 8:51 PM, Jeff Byrnes [jeff@evertrue.com](mailto:jeff@evertrue.com) wrote:  
> The environment is set when converging the node. With a Chef Server, you’d set it on the initial bootstrap, and it would stick moving forward from there.
> 
> With chef-solo, you run the chef-solo command on each particular instance. You’ll need to either specify a config file that provides the values for the particular node you’re bootstrapping, or set the environment directly in the chef-solo command using the environment flag (-E or --environment).
> 
> E.g., sudo chef-solo -E prod -N my-new-node -o role[my-new-role]
> 
> Might need some quotes in there, but that’s kind of the idea. Others might have more experience in this realm, however.
> 
> See the docs on Chef Solo, specifically here: [chef-solo](http://docs.opscode.com/chef_solo.html#chef-solo-executable) for full details on the arguments it takes.
> 
> ## It’d probably be easier to deploy a config file particular to each node as part of your deployment process, and tell Chef Solo to read that config file, instead of specifying things in the command itself. E.g., sudo chef-solo -c ~/chef/solo.rb
> 
> Jeff Byrnes  
> @berkleebassist  
> Operations Engineer  
> EverTrue  
> 704.516.4628
> 
> On March 17, 2014 at 11:13:37 AM, Venkat Chowdhary (nit\_venki2002@yahoo.co.in) wrote:  
> Hi
> 
> I am using chef-solo. I am creating environments (dev.json) manually like below:
> 
> {  
> "name": "dev",  
> "description": "Development Environment",  
> "cookbook\_versions": {  
> },  
> "json\_class": "Chef::Environment",  
> "chef\_type": "environment",  
> "default\_attributes": {  
> },  
> "override\_attributes": {  
> }  
> }
> 
> Could you please help me how to add nodes to different environments like (dev, staging, production etc ...)
> 
> Your help is highly appreciable.
> 
> Thanks in advance.
> 
> Thanks & Regards  
> Venkat
