Ask Your Question
0

I'm adding a custom fact to a module, during agent run I get the error "Facter: error while resolving custom facts in ...: a block must be provided. What does that mean? [closed]

asked 2017-11-08 14:21:16 -0600

updated 2017-11-08 17:23:52 -0600

the code is: <module>lib/facter/ldapsuffix.rb require 'facter'

Facter.add("ldapsuffix") do
    setcode do
        domain = Facter.value('domain').split('.')
        list = []
        domain.each do |x| 
            list << "dc=" + x 
        end 
        list.join(',')
    end 
end
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Kai Burghardt
close date 2017-11-09 17:52:32.417994

Comments

the error returned is: Info: Loading facts Error: Facter: error while resolving custom facts in /opt/puppetlabs/puppet/cache/lib/facter/ldapsuffix.rb: a block must be provided

sandholm gravatar imagesandholm ( 2017-11-08 14:23:57 -0600 )edit

idk, but it reads like a Ruby error message rather than Puppet. Have you tried decomposing the final statement to “list = list.join(',')” and then on a separate line just “list”? Otherwise, if nothing helps, go through your code line by line, marking till when it works.

Kai Burghardt gravatar imageKai Burghardt ( 2017-11-08 17:39:12 -0600 )edit

Thanks for the reply. Turned out the cut-n-paste I did put some funky chars into the code. A delete and a manual re-key, now it works. Go figure?

sandholm gravatar imagesandholm ( 2017-11-09 05:46:20 -0600 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2017-11-09 05:47:01 -0600

cut-n-paste produced unprintable chars in code, making it appear corrupted. A delete & manual re-entry solved the issue.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2017-11-08 14:21:16 -0600

Seen: 39 times

Last updated: Nov 09