# How to use a override attribute in environments

**URL:** <https://discourse.chef.io/t/how-to-use-a-override-attribute-in-environments/4221>\
**Category:** Chef Infra (archive)\
**Created:** [July 20, 2013, 8:00pm UTC](https://discourse.chef.io/t/how-to-use-a-override-attribute-in-environments/4221 "2013-07-20T20:00:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Montgomery](https://avatars.discourse-cdn.com/v4/letter/d/51bf81/32.png) [@David\_Montgomery](https://discourse.chef.io/u/David_Montgomery)\
**Post date:** [July 20, 2013, 8:00pm UTC](https://discourse.chef.io/t/how-to-use-a-override-attribute-in-environments/4221/1 "2013-07-20T20:00:07Z")

</div>

Hi

In my development environment I would like to use the below

name "development"  
description "The development environment"  
default[‘chef\_client’][‘handler’][‘graphite’][‘host’] = “  
[monitor.dev.test.com](http://monitor.dev.test.com)”

knife environment from file  
/home/ubuntu/workspace/feed-chef/chef-repo/environments/development.rb  
ERROR: knife encountered an unexpected error  
This may be a bug in the ‘environment from file’ knife command or plugin  
Please collect the output of this command with the `-VV` option before  
filing a bug report.  
Exception: NameError: undefined local variable or method `default’ for  
development:Chef::Environment

In the cookbook attribute file:  
default[‘chef\_client’][‘handler’][‘graphite’][‘host’] = “  
[monitor.dev.test.com](http://monitor.dev.test.com)”

So…what is the proper format to override the the environment?

Thanks

---

<div class="post-metadata">

**Author:** ![Joshua\_Miller1](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/joshua_miller1/32/349_2.png) [@Joshua\_Miller1](https://discourse.chef.io/u/Joshua_Miller1)\
**Post date:** [July 20, 2013, 8:45pm UTC](https://discourse.chef.io/t/how-to-use-a-override-attribute-in-environments/4221/2 "2013-07-20T20:45:30Z")

</div>

Check out the definition and syntax of "default\_attributes" under  
[http://docs.opscode.com/essentials\_environments.html](http://docs.opscode.com/essentials_environments.html)

Also note that "override" in this case is an overloaded term. The same  
page includes the attribute precedence table.

On Sat, Jul 20, 2013 at 1:00 PM, David Montgomery \<[davidmontgomery@gmail.com](mailto:davidmontgomery@gmail.com)

> wrote:

> Hi
> 
> In my development environment I would like to use the below
> 
> name "development"  
> description "The development environment"  
> default['chef\_client']['handler']['graphite']['host'] = "  
> [monitor.dev.test.com](http://monitor.dev.test.com)"
> 
> knife environment from file  
> /home/ubuntu/workspace/feed-chef/chef-repo/environments/development.rb  
> ERROR: knife encountered an unexpected error  
> This may be a bug in the 'environment from file' knife command or plugin  
> Please collect the output of this command with the `-VV` option before  
> filing a bug report.  
> Exception: NameError: undefined local variable or method `default' for  
> development:Chef::Environment
> 
> In the cookbook attribute file:  
> default['chef\_client']['handler']['graphite']['host'] = "  
> [monitor.dev.test.com](http://monitor.dev.test.com)"
> 
> So..what is the proper format to override the the environment?
> 
> Thanks

---

<div class="post-metadata">

**Author:** ![David\_Montgomery](https://avatars.discourse-cdn.com/v4/letter/d/51bf81/32.png) [@David\_Montgomery](https://discourse.chef.io/u/David_Montgomery)\
**Post date:** [July 20, 2013, 9:59pm UTC](https://discourse.chef.io/t/how-to-use-a-override-attribute-in-environments/4221/3 "2013-07-20T21:59:26Z")

</div>

The is a very nested hash.....I am aware of that page...how do I avoid the  
use of the =\> notation

On Sun, Jul 21, 2013 at 4:45 AM, Joshua Miller [joshuamiller01@gmail.com](mailto:joshuamiller01@gmail.com)wrote:

> Check out the definition and syntax of "default\_attributes" under  
> [http://docs.opscode.com/essentials\_environments.html](http://docs.opscode.com/essentials_environments.html)
> 
> Also note that "override" in this case is an overloaded term. The same  
> page includes the attribute precedence table.
> 
> On Sat, Jul 20, 2013 at 1:00 PM, David Montgomery \<  
> [davidmontgomery@gmail.com](mailto:davidmontgomery@gmail.com)\> wrote:
> 
> > Hi
> > 
> > In my development environment I would like to use the below
> > 
> > name "development"  
> > description "The development environment"  
> > default['chef\_client']['handler']['graphite']['host'] = "  
> > [monitor.dev.test.com](http://monitor.dev.test.com)"
> > 
> > knife environment from file  
> > /home/ubuntu/workspace/feed-chef/chef-repo/environments/development.rb  
> > ERROR: knife encountered an unexpected error  
> > This may be a bug in the 'environment from file' knife command or plugin  
> > Please collect the output of this command with the `-VV` option before  
> > filing a bug report.  
> > Exception: NameError: undefined local variable or method `default' for  
> > development:Chef::Environment
> > 
> > In the cookbook attribute file:  
> > default['chef\_client']['handler']['graphite']['host'] = "  
> > [monitor.dev.test.com](http://monitor.dev.test.com)"
> > 
> > So..what is the proper format to override the the environment?
> > 
> > Thanks

---

<div class="post-metadata">

**Author:** ![Joshua\_Timberman](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/joshua_timberman/32/424_2.png) [@Joshua\_Timberman](https://discourse.chef.io/u/Joshua_Timberman)\
**Post date:** [July 20, 2013, 11:23pm UTC](https://discourse.chef.io/t/how-to-use-a-override-attribute-in-environments/4221/4 "2013-07-20T23:23:39Z")

</div>

Simply put, you don't. The autovivvified hash notation available to node attributes in cookbook attributes files and recipes is not available in the Ruby DSL for roles. The Ruby DSL for roles is translated to JSON by knife on upload to the Chef Server, and the JSON is purely a hash data structure.

Cheers  
Joshua

On Jul 20, 2013, at 3:59 PM, David Montgomery [davidmontgomery@gmail.com](mailto:davidmontgomery@gmail.com) wrote:

> The is a very nested hash.....I am aware of that page...how do I avoid the use of the =\> notation
> 
> On Sun, Jul 21, 2013 at 4:45 AM, Joshua Miller [joshuamiller01@gmail.com](mailto:joshuamiller01@gmail.com) wrote:  
> Check out the definition and syntax of "default\_attributes" under [http://docs.opscode.com/essentials\_environments.html](http://docs.opscode.com/essentials_environments.html)
> 
> Also note that "override" in this case is an overloaded term. The same page includes the attribute precedence table.
> 
> On Sat, Jul 20, 2013 at 1:00 PM, David Montgomery [davidmontgomery@gmail.com](mailto:davidmontgomery@gmail.com) wrote:  
> Hi
> 
> In my development environment I would like to use the below
> 
> name "development"  
> description "The development environment"  
> default['chef\_client']['handler']['graphite']['host'] = "[monitor.dev.test.com](http://monitor.dev.test.com)"
> 
> knife environment from file /home/ubuntu/workspace/feed-chef/chef-repo/environments/development.rb  
> ERROR: knife encountered an unexpected error  
> This may be a bug in the 'environment from file' knife command or plugin  
> Please collect the output of this command with the `-VV` option before filing a bug report.  
> Exception: NameError: undefined local variable or method `default' for development:Chef::Environment
> 
> In the cookbook attribute file:  
> default['chef\_client']['handler']['graphite']['host'] = "[monitor.dev.test.com](http://monitor.dev.test.com)"
> 
> So..what is the proper format to override the the environment?
> 
> Thanks
