On 2015-20-09 18:58, Frédéric Lespez wrote:
In a manifest, you can test the built-in variable $clientnoop to know if
puppet agent runs in noop mode or not.
See
https://docs.puppetlabs.com/puppet/latest/reference/lang_facts_and_builtin_vars.html#puppet-agent-facts
But inside a custom function, how can you know if noop is enabled or not ?
It seems that you cannot access the built-in variable $clientnoop inside
function.
Any clues ?
In the 3.x function API use:
lookupvar('varname')
In the 4.x function API use:
closure_scope.lookupvar('varname')
Here is the specification for the 4.x API.
https://github.com/puppetlabs/puppet-specifications/blob/master/language/func-api.md
Note that closure_scope in the 4.x API does not give access to the
variables in the scope calling the function, but it does provide access
to global variables.
Also consider looking up the $facts hash instead of directly looking up
individual facts like $clientnoop. This to be future proof. (See the
link you posted regarding details).
Regards
- henrik
Regards,
Fred
--
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 [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/325d8144-5836-4581-8cd2-3f5e3c44ce95%40googlegroups.com
<https://groups.google.com/d/msgid/puppet-users/325d8144-5836-4581-8cd2-3f5e3c44ce95%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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/mtovrr%24f6c%241%40ger.gmane.org.
For more options, visit https://groups.google.com/d/optout.