On 26/01/17 08:35, Sans wrote:
Hi Henrik,
Thanks for commenting. Could you elaborate "Only reference Facter in
logic that implements facts" pls? Does it mean when defining, e.g. a
custom-fact, it's okay to reference another fact but not anywhere else?
People gave me so many advice about dos and don'ts but no one actually
explain why it's not working or how can I do it. Regardless of it should
be done or not, why it works for thing like /Facter.value(:hostname)/
but not with like: /Facter.value(:my_external_fact)/?
Basically, I have some external facts setup, during the initial machine
provisioning and then I wanna make sure those facts are defined, if not
put those facts in the external_fact file with some default value. That
template is to maintain that external_fact file - that's my case.
-San
The process is that "facter" runs on the agent, it computes the values
of all the facts for the node. It then sends those to the master which
produces a catalog by compiling manifests. The catalog compiler logic
makes the facts for the node available in $facts hash and in individual
top scope variables (for backwards compatibility reasons). Those are the
fact values that all logic on the master should use. They may not come
directly from facter. So... don't call Facter methods in your templates.
The master is also a node, and running Facter on it may produce the
facts for the master!
Facter is a singleton and it is undefined what happens if you call it
from different environments on the same server.
So, repeating - where did you get the advice (or idea) to call Facter
methods? I want to make sure that place gets updated.
It is obviously easy to confuse "computing the value of a fact x", with
"what is the value of fact x for node y".
- henrik
On Wednesday, January 25, 2017 at 11:23:06 PM UTC, Henrik Lindberg wrote:
Do not ever reference Facter directly on the master side from functions
or ERB templates used when compiling. Only reference Facter in logic
that implements facts. It should be safe to reference Facter on the
agent side in provider logic.
If you have been advised to use Facter directly in templates I would
like to know where that advice came from.
You want to reference @facts['factname'] in an ERB if you are on a
modern puppet, otherwise individual top scope variables.
- henrik
--
Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/
<http://puppet-on-the-edge.blogspot.se/>
--
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
<mailto:puppet-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/e45d81c5-f66a-4c29-960b-c52cbc334486%40googlegroups.com
<https://groups.google.com/d/msgid/puppet-users/e45d81c5-f66a-4c29-960b-c52cbc334486%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/
--
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/o6cl5r%241uo%241%40blaine.gmane.org.
For more options, visit https://groups.google.com/d/optout.