Upgrade from facter 3.11.14 to 4.2.5 (puppet-agent 5 to 7) broke some of 
our custom facts, that use other (custom) facts.
Managed to find the smallest examples of two custom facts that reproduce 
the problem. 

First fact, that uses a core fact:

Facter.add(:my_fact) do
  hostname=Facter.value(:networking)['hostname']
  setcode do
    hostname
  end
end

Second fact, that uses the first fact:

my_fact = Facter.value(:my_fact)
Facter.add(:my_new_fact) do
  setcode do
    my_fact
  end
end

The first fact works, it's the second one that stops working with 
puppet7/facter4.

puppet5/facter3:
amvdi-it133:~# facter -p my_fact my_new_fact
my_fact => amvdi-it133
my_new_fact => amvdi-it133

puppet7/facter4:
mvdi-it133:~# facter -p my_fact my_new_fact
my_fact => amvdi-it133
my_new_fact => 

Seems to have to do with calling Facter.vaiue in the first fact.
This still does not work:

Facter.add(:my_fact) do
  unused=Facter.value(:networking)['hostname']
  hostname="testing"
  setcode do
  ...

But this does:

Facter.add(:my_fact) do
  hostname="testing"
  setcode do
  ...

# facter -p my_fact my_new_fact
my_fact => testing
my_new_fact => testing

Also found that it works if I change the second fact to do the Facter.value 
inside the setcode block:

Facter.add(:my_new_fact) do
  setcode do
    my_fact = Facter.value(:my_fact)
    my_fact
  end
end

Learning this I went back to the first fact and changed it to do the 
Facter.value inside the setcode block too like this:

Facter.add(:my_fact) do
  setcode do
    hostname=Facter.value(:networking)['hostname']
    hostname
  end
end

That also makes it work regardless of where I do Facter.value in the second 
fact.

I'm at a loss as to what the fact is going on here. Is it a bug? Or is 
there a reasonable explanation for it? (I'm a complete Ruby noob, )

Regards,
Mark.

-- 
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/3b0fe404-3218-41b0-82d0-9f4927a776b1n%40googlegroups.com.

Reply via email to