- From: AJ Christensen <
>
- To:
- Subject: [chef] Re: Re: Re: Re: Access node attributes in a library
- Date: Fri, 3 Aug 2012 13:37:15 +1200
Here's an example of what James Winsor was talking about (#1):
https://github.com/fujin/chef-discovery/blob/master/libraries/recipe.rb#L17
Note how I'm able to use the 'node' in the Chef::Recipe without the
user having to pass it into the method(s).
Cheers,
--AJ
On 3 August 2012 13:30, James Light
<
>
wrote:
>
Not sure if this is the problem or not, but I know in Ruby any variable name
>
that starts with an uppercase letter is a constant.
>
>
-JL
>
>
On Aug 2, 2012 3:47 PM,
>
<
>
>
wrote:
>
>
>
> Disclaimer: I am a Ruby newbie
>
>
>
> Trying to follow the first option, i changed the following:
>
> Moved the recipe function into a module
>
> Included the module into the recipe
>
>
>
> <code>
>
> module LogLib
>
> def logEvent(s)
>
> stomp_server = @node[:stomp_server]
>
> Chef::Log.info ("#{stomp_server}");
>
> end
>
> end
>
>
>
> class Chef::Recipe::LOG
>
> include LogLib
>
> end
>
> </code>
>
>
>
> But when I invoke LOG.logEvent "custom event" from a different cookbook's
>
> recipe for testing, I got an error:
>
> NameError: uninitialized constant Chef::Recipe::LOG::LogLib
Archive powered by MHonArc 2.6.16.