Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I created a simple custom fact:

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

and put it here (on puppetmaster):

/etc/puppet/modules/custom/lib/facter

I'm testing it on puppet client:

facter hello

and see nothing.

Whereas this command works (on puppet client):

facter --puppet hello
Hello, world

Checking if the fact is synced (on puppet client):

puppetd --test --pluginsync
info: Retrieving plugin
info: Loading facts in /var/lib/puppet/lib/facter/hello.rb
info: Caching catalog for host.example.com

It looks like the custom fact is synced fine. I can't understand why it's not available via facter.

Also, how can I use this new fact from puppetmaster? I need to build a simple conditional based on the custom fact.

For example, I added in site.pp (on puppetmaster):

$string = "$hello"
notice("Testing custom fact: $string")

Again, in syslog there is no line from the notice function.

I studied a lot of documentation and still can't get how to make it work. I will appreciate if someone could look on this issue.

Thank you.

Configuration: Ubuntu Server 12.04, Puppet 2.7.11, facter 1.6.5

share|improve this question

1 Answer 1

up vote 0 down vote accepted

The custom facts from puppet are only used in puppet runs or when you use the --puppet flag on facter. If you're not ok with that, then put the custom facts somewhere that facter will always use - see here for details.

The fact should be present for the catalog compile; you probably aren't logging notice messages. To use it as a condition:

if $hello == "Hello, world" {
  notify { "found": }
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.