Where do custom facter facts go on the Learning VM ? Is that the cause of these behaviors?

1,134 views
Skip to first unread message

Shark Laser

unread,
Jan 8, 2014, 4:52:30 PM1/8/14
to puppet...@googlegroups.com

Platform:  I've downloaded and installed the learning VM.   This system runs CentOS with Facter v1.7.3 and Puppet v3.3.1 (Puppet Enterprise 3.1.0). 

I've created a fact called hello.rb with the following content:

       Facter.add(:hello) do
           setcode do
              "Hello world!"
           end
       end


I've placed the file in /etc/puppetlabs/facter/facts.d (I made this directory since the tutorial said to create it if it did not exist).
I added a line to /etc/puppetlabs/puppet/manifests/site.pp for the default node:   notify  { $::hello: } .    If I run puppet agent --test, it behaves as if my custom fact does not exist:

Notice:  undef
Notice: /Stage[main]//Node[default]/Notify[undef]/message: defined 'message' as 'undef'


So then the instructions said we could debug the fact by running facter --debug.  If I do this, I see an error: 

Fact file /etc/puppetlabs/facter/facts.d/hello.rb was parsed but returned an empty data set

I thought this meaningful but the same error will occur for any Facter custom fact I put in there.   Even verbatim copy/paste jobs from known working examples off the tutorial.      Does anyone know what is going on?    I can't tell if the fact is in the wrong directory for Puppet when it uses Facter, but for some reason Facter sees it when run in standalone?    If the latter is the case, why do I get these parse errors despite having valid source?

Thanks for any help.





Nathan Valentine

unread,
Jan 8, 2014, 7:40:10 PM1/8/14
to puppet...@googlegroups.com
You are making external facts too complicated. More like this:


hello.rb
-----------
#!/usr/bin/env ruby
puts "hello=Hello, World!"


hello.yaml
---------------
---
hello='Hello, World!'


https://docs.puppetlabs.com/guides/custom_facts.html#external-facts


--
---
Nathan Valentine, Puppet Labs Professional Services
Have you seen : http://ask.puppetlabs.com , http://puppetlabs.com/learn ?

Nathan Valentine

unread,
Jan 8, 2014, 7:50:11 PM1/8/14
to puppet...@googlegroups.com
sorry, s/=/:/g in hello.yaml

Shark Laser

unread,
Jan 8, 2014, 8:03:52 PM1/8/14
to puppet...@googlegroups.com
The simpler ruby script you gave still exhibits the same behavior.  I'm sure the code in the facts I am using is correct, so I don't think it is a matter of their content.   As I mentioned I have literally copied examples from the tutorial and elsewhere.  

If I run facter --debug all of the facts give the same error message I give above that they were parsed but returned an empty dataset.

If I run puppet agent --test then it is as if my fact did not exist.        

Any ideas?

Nathan Valentine

unread,
Jan 8, 2014, 10:01:28 PM1/8/14
to puppet...@googlegroups.com
The Facter.add scaffolding isn't required for external facts. That's
actually a key part of the design.

Here's an example vagrant environment with external facts similar to
your demo code:

https://github.com/nrvale0/vagrant-extfacts-demo
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/faf70d9b-d15f-4f23-a058-f2ef79189636%40googlegroups.com.
>
> For more options, visit https://groups.google.com/groups/opt_out.

Andrey Kozichev

unread,
Jan 9, 2014, 2:55:17 AM1/9/14
to puppet...@googlegroups.com

i think everything is fine with your code.
Problem might be with location.

Dont know about PE, but for facter if you do export FACTERLIB= <you dir>, then you can run facter to see your custom fact

--
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...@googlegroups.com.

Johan De Wit

unread,
Jan 9, 2014, 11:25:09 AM1/9/14
to puppet...@googlegroups.com
The facts should go into :

/etc/puppetlabs/puppets/module/hello/lib/facter/

if you do a puppet agent -t, it will deployed in the right place by puppet.

you can also do a 'puppet plugin download'

hope this helps
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/90578665-1151-4df5-8a46-27e03ab877d6%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


-- 
Johan De Wit

Open Source Consultant

Red Hat Certified Engineer         (805008667232363)
Puppet Certified Professional 2013 (PCP0000006)
_________________________________________________________
 
Open-Future                 Phone     +32 (0)2/255 70 70
Zavelstraat 72              Fax       +32 (0)2/255 70 71
3071 KORTENBERG             Mobile    +32 (0)474/42 40 73
BELGIUM                     http://www.open-future.be
_________________________________________________________
 

Upcoming Events:

Puppet Fundamentals Training | http://www.open-future.be/puppet-fundamentals-training-4-till-6th-february

Puppet Introduction Course | http://www.open-future.be/puppet-introduction-course-7th-february

Zabbix Certified Training | http://www.open-future.be/zabbix-certified-training-10-till-12th-february

Zabbix for Large Environments Training | http://www.open-future.be/zabbix-large-environments-training-13-till-14th-february

Subscribe to our newsletter: http://eepurl.com/BUG8H


Shark Laser

unread,
Jan 9, 2014, 1:38:55 PM1/9/14
to puppet...@googlegroups.com
Thank you Andrew and Johan.

Andrew's suggestion made the fact work with Facter when run alone (outside of Puppet) such as "facter --debug"  -- the value of my new hello fact shows up in the output now

Johan's suggestion got it working when I run Puppet from the commandline.   If I do "puppet agent --test" then I see the the value printed out with the notify line I put in sites.pp

That helped a lot! 
Reply all
Reply to author
Forward
0 new messages