On 2014-10-12 12:03, Spriya wrote:
> Hi,
>
> I have a requirement that,
>
> *I have list of two different facts*
>
> *java_foundversion1_path1
> java_foundversion2_path2
> java_foundversion3_path3
> java_foundversion4_path4*
>
> *and java_authorizedversion1path1
> java_authorizedversion2path2
> java_authorizedversion3path3
> java_authorizedversion4path4*
>
> *and i am trying to compare each facts with all facts i.e
> java_found_version1path1 to all the list of java_authorized*. And if
> it founds any facts equal to java_found1version1path. It should notify
> us.*
>
> *
> *
>
> *
> *
>
> Is anything we can do it in puppet manifests?
>
If you are on puppet 3.7 you can easily iterate over facts. If you are
using future parser this can be done in
the puppet language, otherwise in Ruby (as a function or in a template).
You need to read
https://docs.puppetlabs.com/puppet/latest/reference/lang_facts_and_builtin_vars.html
to
understand which flags (if any) you need to change to get all the facts
into the variable $facts.
(The setting 'trusted_node_data = true' turns on the support I am using
in the example below).
If you are on a version before 3.7, it is much more difficult to do this
inside a manifest as it is difficult to
know which global variables are facts and which are not. You would
instead need to lookup the facts for a node
and act on that output directly with your own code).
With future parser you could do something like this:
$facts.each |$key, $val | {
if $key == 'the value you are looking for' {
# fail or notify or something
}
}
Hope that helps as a starting point.
Regards
- henrik
--
> 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...@googlegroups.com
> <mailto:
puppet-users...@googlegroups.com>.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/puppet-users/61cd8170-b4f8-4037-934e-e0bf442c82e1%40googlegroups.com
> <
https://groups.google.com/d/msgid/puppet-users/61cd8170-b4f8-4037-934e-e0bf442c82e1%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/