On 22/08/17 18:30, John Baird wrote:
    Henrik,


I have something that appears to be at least "attempting" to find the proper files.  The issue I am currently running into is that the "key" or file that I am looking for is being "chopped" at the first ".", which in this case is actually in a folder name, not the file extension.  Do you know how to avoid that?

*# File Backend for Hiera*
*Puppet::Functions.create_function(:'file_backend') do*
*
*
*  dispatch :file_backend do*
*    param "String", :key*
*    param "Hash", :options*
*    param "Puppet::LookupContext", :context*
*  end*
*
*
*  argument_mismatch :missing_path do*
*    param 'Hash', :options*
*    param 'Puppet::LookupContext', :context*
*  end*
*
*
*  def file_backend(key, options, context)*
*    hieradir   = context.interpolate(options['hieradir'])*
*    searchroot = context.interpolate(options['searchroot'])*
*    searchpath = hieradir + searchroot*
*    if (File.exists?("#{searchpath}/#{key}"))*
*      data = File.read("#{searchpath}/#{key}")*
*    else*
*      context.explain() { "SearchPath: #{searchpath}, Key: #{key}"}*
*      context.not_found()*
*    end*
*  end*
*
*
*  def missing_path(options, context)*
*    "one of 'path', 'paths', 'glob', 'globs', or 'mapped_paths' must be declared in hiera.yaml when using this file_backend function"*
*  end*
*end*
*
*
When looking up '*/etc/dd-agent/checks.d/filename.py'* I receive a `*Function lookup() did not find a value for the name '/etc/dd-agent/checks.d/filename.py*`.

The debugging from the puppet lookup outputs *KEY: /etc/dd-agent/checks *which does not contain the rest of the filename or path.

Only had a quick look at the code. I think the issue you are seeing is that a '.' has special meaning - it navigates into a structure, you need to escape dots in the key - IIRC by quoting them. Try with a key that does not have a '.', and then try with quoting the dot with "" or ''

The dot-syntax is typically used to navigate into arrays and hashes.

Best,
- henrik

Thoughts ?

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com <mailto:puppet-users+unsubscr...@googlegroups.com>. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/7a86b718-434c-42ff-ad50-649f276c75ba%40googlegroups.com <https://groups.google.com/d/msgid/puppet-users/7a86b718-434c-42ff-ad50-649f276c75ba%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.


--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/onifdt%24ia6%241%40blaine.gmane.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to