[chef] Re: RE: Re: Knife search shows attributes but cannot find same attribute in recipe


Chronological Thread 
  • From: AJ Christensen < >
  • To: " " < >
  • Subject: [chef] Re: RE: Re: Knife search shows attributes but cannot find same attribute in recipe
  • Date: Fri, 6 Feb 2015 20:57:21 +1300

try `node.debug_value(:tc, :user)` in a chef-shell with the attributes loaded or in your Recipe DSL [0]; you should be able to determine the source of your attribute woes. Given that you have not shared with us your attribute structure (cookbooks, roles, environments, json attributes, ohai custom plugins) without additional diagnostics, my recommendations are limited.

Please provide a full debug log if possible, too! `-ldebug` or similar. 

cheers,

--aj


On Fri, Feb 6, 2015 at 8:47 PM, M G < " target="_blank"> > wrote:
Hi AJ

OK. I ran the recipe using your suggestion and still the variable tcuser comes up empty when running on the node.

knife search node name:devwsgw20150130113529 -a tomcat
1 items found

devwsgw20150130113529:
  tomcat:
    base: /opt/apache-tomcat-7.0.54
    user: tomcat

As you can see the attribute tomcat has two child attributes base and user with values in them.

In the recipe, I have the following code:

tc=node.attribute[:tomcat][:base]
log "tc base is #{tc}"
tcuser=node['tomcat']['user']
log "tc user is #{tcuser}"

And while running it I get 

  * log[tc base is /opt/apache-tomcat-7.0.54] action write

  * log[tc user is ] action write

So you see using the colon notation I am able to get the value of tomcat's child attribute "base" 
but using the colon notation and your suggested notation I get nothing.  This is strange behavior that I have not encountered .

Any suggestions/pointers ?

Regards

mg


Date: Fri, 6 Feb 2015 17:45:11 +1300
From:
To: " target="_blank">
Subject: [chef] Re: Knife search shows attributes but cannot find same attribute in recipe


```
tcuser=node.attribute[:tomcat][:user]
log "tc user is #{tcuser}"
```

this is wrong, you want something like:

```
tcuser = node['tomcat']['user']
```

in your Recipe. I don't know that `node.attribute` does what you mean.

cheers,

--aj

On Fri, Feb 6, 2015 at 5:42 PM, M G < " target="_blank"> > wrote:
Hi

When i do 

knife search node name:devwsgw20150130113529 -a tomcat.user
1 items found

devwsgw20150130113529:
  tomcat.user: tomcat

I see there is an attribute called tomcat.user

In recipe I am using,

tcuser=node.attribute[:tomcat][:user]
log "tc user is #{tcuser}"


When I run the chef-client on the above node, i see the following line printed

Compiling Cookbooks...
Converging 14 resources
Recipe: update::deploy
  * log[tc user is ] action write

Why can knife search the attribute and the recipe cannot?

Please provide pointers/suggestions.

Regards

mg








Archive powered by MHonArc 2.6.16.

§