On Wednesday, January 14, 2015 at 5:53:04 AM UTC-6, Ashish Jaiswal wrote:
>
> Hi, 
>
> I have a custom facter which spits out like this 
> # facter -p 
>      xfs_mounts => ["/docroot", "/ecr", "/intprd", "/mysql"] 
>
> Now I want to iterate over this. so thought lambda is the one. 
>
>    $a=$xfs_mounts 
>    each($a) | $value | { device { $value : } } 
>
> which is not working, giving error as follows 
>
> Error: Could not retrieve catalog from remote server: Error 400 on 
> SERVER: Evaluation Error: Error while evaluating a Resource Statement, 
> Duplicate declaration: Monit::Device[o] is already declared in file 
> /home/edp/rpuppet/master/modules/monit/manifests/init.pp:147; cannot 
> redeclare at 
> /home/edp/rpuppet/master/modules/monit/manifests/init.pp:147 at 
> /home/edp/rpuppet/master/modules/monit/manifests/init.pp:147:25 on node 
> example.com 
>
> Its taking the whole xfs_mounts, which I don't want. 
>


If you mean Puppet is interpreting the fact as a single string rather than 
an array, then I think you are correct.  Inasmuch as you have not presented 
your fact code, however, I cannot tell whether yours is a structured fact 
at all (so that the problem is in Puppet's handling of it), or whether it 
is fundamentally a string in the first place.

If yours is indeed a structured fact, whose value in the example is a 
four-element array, then your issue is probably that structured facts are 
not enabled in Puppet.  Agent and master must both be configured with the 
'stringify_facts' option explicitly turned off (best to do this in the 
[main] section of all your puppet configs).  That option is *on* by default.

If yours is not actually a structured fact in the first place then in 
addition to the above, you also need to rewrite the fact as a structured 
one.

See the custom fact documentation 
<https://docs.puppetlabs.com/facter/2.3/fact_overview.html#writing-structured-facts>
 
for more information.


John

-- 
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/86ad7660-b426-4267-aec0-8eb5c2dac848%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to