On Wed, Aug 3, 2011 at 4:15 PM, Aaron Grewell <aaron.grew...@gmail.com>wrote:

> Precedence is for having it look in multiple places.  I've got node-level,
> site-level, and default YAML files for example.
>
> On Wed, Aug 3, 2011 at 3:50 PM, Douglas Garstang 
> <doug.garst...@gmail.com>wrote:
>
>> Can't get the extlookup() that supports yaml to work.
>>
>> I did this...
>>
>> On server:
>> mv /usr/lib/ruby/site_ruby/1.8/puppet/parser/functions/extlookup.rb
>> /usr/lib/ruby/site_ruby/1.8/puppet/parser/functions/extlookup.rb.orig
>> Replaced /usr/lib/ruby/site_ruby/1.8/puppet/parser/functions/extlookup.rb
>> with puppet-extlookup/lib/puppet/parser/functions/extlookup.rb
>> mkdir /usr/lib/ruby/site_ruby/1.8/puppet/util/extlookup/
>> Added puppet-extlookup/lib/puppet/util/extlookup.rb to
>> /usr/lib/ruby/site_ruby/1.8/puppet/util
>> Added puppet-extlookup/lib/puppet/util/extlookup/csv_parser.rb to
>> /usr/lib/ruby/site_ruby/1.8/puppet/util/extlookup
>> Added puppet-extlookup/lib/puppet/util/extlookup/yaml_parser.rb to
>> /usr/lib/ruby/site_ruby/1.8/puppet/util/extlookup
>> Added puppet-extlookup/lib/puppet/util/extlookup/puppet_parser.rb to
>> /usr/lib/ruby/site_ruby/1.8/puppet/util/extlookup
>>
>> Created /etc/puppet/extlookup.yaml:
>> ---
>> :parser: YAML
>> :precedence:
>> - environment_%{environment}
>> - common
>> :yaml:
>>   :datadir: /etc/puppet/extdata
>>
>> Created /etc/puppet/extdata/settings.yaml:
>> ---
>> testkey: testval
>>
>> Calling with:
>>         $test_var = extlookup('testkey', '---', 'settings.yaml')
>>         notice("TEST VAR=$test_var")
>>
>> And $test_var is always '---'. Replacing settings.yaml with a bogus file
>> name also returns '---', which tells me that the file isn't being found.
>> What am I missing here? Quite possibly a lot given the really bad docs.
>>
>> What is 'precedence' for? Not documented.
>>
>> Doug.
>>
>>
>>
Thanks Aaron. Seems you've had some experience with this, so..

I'm a little confused about how it loads complex data. With a very simple
YAML file like this:

---
testkey:
- Doug
- Bob
- Bill

calling $test_var = extlookup('testkey', '---', 'settings') gives me a
string 'DougBobBill', which isn't what I expected to see. Actually, now that
I think about it, I'm not sure what I'm supposed to see.

Also, if I had this:

---
testkey1:
  testkey2:
    - Doug

how do I access the key testkey2?

Doug.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to