# How to manage and deploy environments?

**URL:** <https://discourse.chef.io/t/how-to-manage-and-deploy-environments/2938>\
**Category:** Chef Infra (archive)\
**Created:** [July 20, 2012, 7:49am UTC](https://discourse.chef.io/t/how-to-manage-and-deploy-environments/2938 "2012-07-20T07:49:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steve\_Bennett](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/steve_bennett/32/646_2.png) [@Steve\_Bennett](https://discourse.chef.io/u/Steve_Bennett)\
**Post date:** [July 20, 2012, 7:49am UTC](https://discourse.chef.io/t/how-to-manage-and-deploy-environments/2938/1 "2012-07-20T07:49:13Z")

</div>

Hi,  
I’m trying to do something that should be really simple:

1. Create “dev” and “prod” environments
2. Specify a couple of attributes that go with each
3. Bootstrap a remote node with “prod” environment

The documentation ([http://wiki.opscode.com/display/chef/Environments](http://wiki.opscode.com/display/chef/Environments))  
suggests that you can create ‘dev.rb’ and ‘prod.rb’ in the environments  
directory, then run ‘rake install’ to upload these to the chef server.  
However, various comments on that page indicate that this is incorrect.

So, how _do_ you manage environment-specific attributes? Isn’t this the  
whole purpose of environments? I really want to manage them through local  
text files - not running commands on the chef server - if possible.

Secondly, how do you then specify that a node should be ‘prod’? I tried  
this:

1. Bootstrap node
2. knife edit node xxxx
3. Run chef-client on node

It failed with a 403 error, but possibly because the environment was not  
properly registered in the first place. Is this the right approach?

Steve

---

<div class="post-metadata">

**Author:** ![Shabnam\_Kumari](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@Shabnam\_Kumari](https://discourse.chef.io/u/Shabnam_Kumari)\
**Post date:** [July 20, 2012, 11:57am UTC](https://discourse.chef.io/t/how-to-manage-and-deploy-environments/2938/2 "2012-07-20T11:57:15Z")

</div>

I don’t want to receive any updation mail regarding chef.Can u please  
unsubscribe my mail Id.

---

<div class="post-metadata">

**Author:** ![Mike](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/mike/32/18_2.png) [@Mike](https://discourse.chef.io/u/Mike)\
**Post date:** [July 20, 2012, 1:07pm UTC](https://discourse.chef.io/t/how-to-manage-and-deploy-environments/2938/3 "2012-07-20T13:07:18Z")

</div>

Hi Steve,

How are you placing the environment on the chef server? I create  
environments locally in the Ruby DSL, then use `knife environment from file environments/myenv.rb` to upload it to the server.

When bootstrapping a new node, I provide the `-E myenv` argument to  
pass that along.

Be aware that environment default\_attributes are overridded by role's  
default//\_attributes, as can be seen here:  
[http://wiki.opscode.com/display/chef/Attributes#Attributes-Precedence](http://wiki.opscode.com/display/chef/Attributes#Attributes-Precedence)

-M

On Fri, Jul 20, 2012 at 3:49 AM, Steve Bennett [stevage@gmail.com](mailto:stevage@gmail.com) wrote:

> Hi,  
> I'm trying to do something that should be really simple:
> 
> 1. Create "dev" and "prod" environments
> 2. Specify a couple of attributes that go with each
> 3. Bootstrap a remote node with "prod" environment
> 
> The documentation ([http://wiki.opscode.com/display/chef/Environments](http://wiki.opscode.com/display/chef/Environments))  
> suggests that you can create 'dev.rb' and 'prod.rb' in the environments  
> directory, then run 'rake install' to upload these to the chef server.  
> However, various comments on that page indicate that this is incorrect.
> 
> So, how _do_ you manage environment-specific attributes? Isn't this the  
> whole purpose of environments? I really want to manage them through local  
> text files - not running commands on the chef server - if possible.
> 
> Secondly, how do you then specify that a node should be 'prod'? I tried  
> this:
> 
> 1. Bootstrap node
> 2. knife edit node xxxx
> 3. Run chef-client on node
> 
> It failed with a 403 error, but possibly because the environment was not  
> properly registered in the first place. Is this the right approach?
> 
> Steve

---

<div class="post-metadata">

**Author:** ![Steve\_Bennett](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/steve_bennett/32/646_2.png) [@Steve\_Bennett](https://discourse.chef.io/u/Steve_Bennett)\
**Post date:** [July 23, 2012, 4:39am UTC](https://discourse.chef.io/t/how-to-manage-and-deploy-environments/2938/4 "2012-07-23T04:39:50Z")

</div>

On 20 July 2012 23:07, Mike [miketheman@gmail.com](mailto:miketheman@gmail.com) wrote:

> Hi Steve,
> 
> How are you placing the environment on the chef server? I create  
> environments locally in the Ruby DSL, then use `knife environment from file environments/myenv.rb` to upload it to the server.
> 
> When bootstrapping a new node, I provide the `-E myenv` argument to  
> pass that along.

Great, I'll try that.

> Be aware that environment default\_attributes are overridded by role's  
> default//\_attributes, as can be seen here:  
> [http://wiki.opscode.com/display/chef/Attributes#Attributes-Precedence](http://wiki.opscode.com/display/chef/Attributes#Attributes-Precedence)

Ah - so I guess there is a "normal\_attributes" command, too? There doesn't  
appear to be any doco for it?

Steve

---

<div class="post-metadata">

**Author:** ![Bryan\_McLellan](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/bryan_mclellan/32/81_2.png) [@Bryan\_McLellan](https://discourse.chef.io/u/Bryan_McLellan)\
**Post date:** [July 23, 2012, 11:51pm UTC](https://discourse.chef.io/t/how-to-manage-and-deploy-environments/2938/5 "2012-07-23T23:51:04Z")

</div>

On Mon, Jul 23, 2012 at 12:39 AM, Steve Bennett [stevage@gmail.com](mailto:stevage@gmail.com) wrote:

> Ah - so I guess there is a "normal\_attributes" command, too? There doesn't  
> appear to be any doco for it?

Not for environments.

Normal attributes are used at the node level. They're usually set on a  
node, or in a cookbook.

Roles and environments can set either default or override attributes.  
Think of it as being able to say, "everything with this role or in  
this environment should default to this setting, or should always have  
this setting."

For example, all the nodes in an prod environment could default to a  
set of DNS servers, except the servers for a particular service could  
default to another set of DNS servers using a role. You might change  
the DNS servers for a specific node by setting a normal attribute  
because it is a special snowflake.

Bryan
