[chef] Re: Re: Attributes merged between roles and environments?


Chronological Thread 
  • From: Douglas Garstang < >
  • To:
  • Subject: [chef] Re: Re: Attributes merged between roles and environments?
  • Date: Tue, 12 Aug 2014 15:11:53 -0700

Thanks Daniel.


On Tue, Aug 12, 2014 at 3:08 PM, Daniel DeLeo < " target="_blank"> > wrote:
On Tuesday, August 12, 2014 at 3:03 PM, Douglas Garstang wrote:
> This seems to be the case, but I thought I'd check, just in case I'm making incorrect assumptions...
>
> Do multi level attributes get 'merged' between environments and roles? Ie, would this environment attribute:
>
> {
> "name": "qa",
> "default_attributes": {
> "mongodb": {
> "cluster_name": "test1"
> }
> }
>
> and this role attribute:
>
> {
> "name": "role-mongo-shard1",
> "default_attributes": {
> "mongodb": {
> "shard_name": "shard1",
> "config": {
> "replSet": "replset1"
> }
> }
> }
> }
>
> be merged into this json?
>
> mongodb": {
> "cluster_name": "test1",
> "shard_name": "shard1",
> "config": {
> "replSet": "replset1"
> }
> }
>
> Or, does one wipe the other?
>
> Thanks,
> Doug.

They’re “deep merged,” which does what you expect as long as everything is a hash (JSON “object” type). With Arrays, it’s tricky because we try to make a compromise that supports two competing use cases (sometimes you want a set union, sometimes you want replacement). The best way to go is just to steer clear of Arrays entirely and it should work as you expect.

--
Daniel DeLeo






--
Regards,

Douglas Garstang
http://www.linkedin.com/in/garstang
Email: ">
Cell: +1-805-340-5627



Archive powered by MHonArc 2.6.16.

§