Question on Attribute Merging

I’m seeing some interesting with attribute merging, and before I get to
deep into the weeds I was wondering what the expected result would be.

We’re consuming a community cookbook and we are altering attributes in for
that cookbook.
It looks looks something like this:

base_role
{
level1 => {
level2 => {
enabled: true # We want this attribute set to true on ALL nodes
}
}
}

app_role
run_list includes base_role
{
level1 => {
level2 => {
proxy_host: ‘something’
}
}
}

I was expecting these to get merged, and I would end up with this on the
app node:
{
level1 => {
level2 => {
enabled: true
proxy_host: ‘something’
}
}
}

But in reality all I’m getting is the enabled:true. If I move the
proxy_host stuff up to the base it works, and if I move the enabled down to
the app_role it also works

I understand I can accomplish what I want with a wrapper cookbook (and that
maybe the route I go), but I was curious if I had wrong expectations that
the merge should happen, or is this expected when your using two roles to
accomplish this.

To be clear I’m not married on this role approach, it just so happens we
have roles, and I tried this thinking it might work and when it didn’t I
started wondering if it should.

Thanks

Pardon the mobile brevity, but could you be hitting this as a result of the
attribute merge?

https://coderanger.net/arrays-and-chef/

On Thursday, January 15, 2015, David Petzel davidpetzel@gmail.com wrote:

I'm seeing some interesting with attribute merging, and before I get to
deep into the weeds I was wondering what the expected result would be.

We're consuming a community cookbook and we are altering attributes in for
that cookbook.
It looks looks something like this:

base_role
{
level1 => {
level2 => {
enabled: true # We want this attribute set to true on ALL nodes
}
}
}

app_role
run_list includes base_role
{
level1 => {
level2 => {
proxy_host: 'something'
}
}
}

I was expecting these to get merged, and I would end up with this on the
app node:
{
level1 => {
level2 => {
enabled: true
proxy_host: 'something'
}
}
}

But in reality all I'm getting is the enabled:true. If I move the
proxy_host stuff up to the base it works, and if I move the enabled down to
the app_role it also works

I understand I can accomplish what I want with a wrapper cookbook (and
that maybe the route I go), but I was curious if I had wrong expectations
that the merge should happen, or is this expected when your using two
roles to accomplish this.

To be clear I'm not married on this role approach, it just so happens we
have roles, and I tried this thinking it might work and when it didn't I
started wondering if it should.

Thanks

I don't believe so (but possibly). In this case the attribute values are
all strings, not arrays in the mix (I've been bitten by that before for
sure though).

On Thu, Jan 15, 2015 at 9:00 PM, Nick Silkey nick@silkey.org wrote:

Pardon the mobile brevity, but could you be hitting this as a result of
the attribute merge?

Arrays and Chef Attributes – Noah Kantrowitz