Facts and Resource relationships

13 views
Skip to first unread message

Erez Zarum

unread,
Oct 6, 2016, 3:40:44 AM10/6/16
to Puppet Users
I'm not sure if it's a bug or an expected behavior.

I have written a simple fact for a module that returns a version of a binary file, it executes: "binary --version" and then parses the version, no issues there, it works.

The issue i am having is relying on this fact in case the binary file gets upgraded during a package installation (this is the simple example)

package { 'package':
 ensure => '1.3.8'
} ->
notify { "version: ${::binary_version}": }

If the previous version was 1.3.7 the fact "binary_version" will return 1.3.7, the next run it will return 1.3.8 as expected.
The biggest issue is if i rely on this fact to pick up a template to use, if this package is not yet installed the fact won't work and will work only on the second run.

I can only assume this happens because the facts are being "compiled" before the catalog is.

I have tried different ways to declare the relationship but it doesn't work.





R.I.Pienaar

unread,
Oct 6, 2016, 3:45:26 AM10/6/16
to puppet-users
yes, you cant use facts for something that changes during a run. It's for facts
about your node that influence the creation of the catalog.

things the catalog changes - well thats after the catalog was created

Erez Zarum

unread,
Oct 6, 2016, 3:49:31 AM10/6/16
to Puppet Users
Ok, so the workaround is to use a variable (set default), if that fails, try the fact.

Thanks!

Rob Nelson

unread,
Oct 6, 2016, 5:49:11 AM10/6/16
to puppet...@googlegroups.com
I do not know that a workaround is needed. I believe that when a package is upgraded, the old and new versions should show up in the logs already, so the notify may not be needed.
--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/1af175d0-ba5d-4626-8fcc-986f6c7fc8f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Erez Zarum

unread,
Oct 6, 2016, 5:57:24 AM10/6/16
to Puppet Users
It was just an example to reproduce it.
Reply all
Reply to author
Forward
0 new messages