# Changing of environment via knife node edit command

**URL:** <https://discourse.chef.io/t/changing-of-environment-via-knife-node-edit-command/5698>\
**Category:** Chef Infra (archive)\
**Created:** [August 6, 2014, 5:31pm UTC](https://discourse.chef.io/t/changing-of-environment-via-knife-node-edit-command/5698 "2014-08-06T17:31:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pratik\_Gadiya](https://avatars.discourse-cdn.com/v4/letter/p/a3d4f5/32.png) [@Pratik\_Gadiya](https://discourse.chef.io/u/Pratik_Gadiya)\
**Post date:** [August 6, 2014, 5:31pm UTC](https://discourse.chef.io/t/changing-of-environment-via-knife-node-edit-command/5698/1 "2014-08-06T17:31:29Z")

</div>

Hi All,

While trying out environments in chef, I tried some steps as mentioned below  
for better understanding usage of environments but could not get why the result  
was something different then what I expected.

Here is what I have tried :

1. I have a recipe. consisting variable x = 5 defined in attributes/attr.rb

2. Then, I created a environment named “testing” for my cookbook named “try”.  
In this newly created environment, I have specified overirde\_attributes  
variable x=10

3. We know that “knife node edit \<node\_name\>” command can be used to edit the  
details of a node. So, moving ahead I edited environment attribute of node  
"client\_one" from “\_default” to that “testing”

4. Now, my expectation was that if I execute recipe “try” against this node it  
should read and print the value of x as 10 but output printed was 5.

Please let me know how the execution in this scenario does not read value of  
variable x from environment.

Thanks

---

<div class="post-metadata">

**Author:** ![DV1](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/dv1/32/186_2.png) [@DV1](https://discourse.chef.io/u/DV1)\
**Post date:** [August 7, 2014, 7:20pm UTC](https://discourse.chef.io/t/changing-of-environment-via-knife-node-edit-command/5698/2 "2014-08-07T19:20:46Z")

</div>

It really depends on what the recipe is printing.. default['try']['x]?  
node['try']['x']? Something else?

On Wed, Aug 6, 2014 at 10:31 AM, [pratik\_gadiya@persistent.co.in](mailto:pratik_gadiya@persistent.co.in) wrote:

> Hi All,
> 
> While trying out environments in chef, I tried some steps as mentioned  
> below  
> for better understanding usage of environments but could not get why the  
> result  
> was something different then what I expected.
> 
> Here is what I have tried :
> 
> 1. I have a recipe. consisting variable x = 5 defined in attributes/attr.rb
> 
> 2. Then, I created a environment named "testing" for my cookbook named  
> "try".  
> In this newly created environment, I have specified overirde\_attributes  
> variable x=10
> 
> 3. We know that "knife node edit \<node\_name\>" command can be used to edit  
> the  
> details of a node. So, moving ahead I edited environment attribute of node  
> "client\_one" from "\_default" to that "testing"
> 
> 4. Now, my expectation was that if I execute recipe "try" against this  
> node it  
> should read and print the value of x as 10 but output printed was 5.
> 
> Please let me know how the execution in this scenario does not read value  
> of  
> variable x from environment.
> 
> Thanks

--  
Best regards, Dmitriy V.

---

<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:** [August 7, 2014, 3:48pm UTC](https://discourse.chef.io/t/changing-of-environment-via-knife-node-edit-command/5698/3 "2014-08-07T15:48:49Z")

</div>

On Wednesday, August 6, 2014 at 10:31 AM, pratik\_gadiya@persistent.co.in wrote:

> Hi All,
> 
> While trying out environments in chef, I tried some steps as mentioned below  
> for better understanding usage of environments but could not get why the result  
> was something different then what I expected.
> 
> Here is what I have tried :
> 
> 1. I have a recipe. consisting variable x = 5 defined in attributes/attr.rb
> 
> 2. Then, I created a environment named "testing" for my cookbook named "try".  
> In this newly created environment, I have specified overirde\_attributes  
> variable x=10
> 
> 3. We know that "knife node edit \<node\_name\>" command can be used to edit the  
> details of a node. So, moving ahead I edited environment attribute of node  
> "client\_one" from "\_default" to that "testing"
> 
> 4. Now, my expectation was that if I execute recipe "try" against this node it  
> should read and print the value of x as 10 but output printed was 5.
> 
> Please let me know how the execution in this scenario does not read value of  
> variable x from environment.
> 
> Thanks  
> Can you show us your recipe code and environments file?

--  
Daniel DeLeo
