On Thu, Jul 05, 2012 at 05:43:10PM +0200, Martin Willemsma wrote:
> Hi,
> 
> I want to use a file resource to write a facts.yaml file for
> Mcollective. For some reason it won't provide a valid yaml format if I
> dump my scope to hash and convert to_yaml.
> 
>       file {
>               "/etc/mcollective/facts.yaml" :
>                       owner => root,
>                       group => root,
>                       mode => 400,
>                       loglevel => debug,
>                       #content => inline_template("<%= scope.to_hash.reject { 
> |k,v| !(
> k.is_a?(String) && v.is_a?(String) ) }.to_yaml %>"),
> 
>                       #content => inline_template("<%= { \"a\" => 1, \"b\"=> 
> 2}.to_yaml %>"),
>                       content =>
>                       inline_template("<%= facts = {}; 
> scope.to_hash.each_pair {|k,v|
> facts[k.to_s] = v.to_s unless k.to_s =~
> /pkg_|_hours|_seconds|memoryfree|plugin_|config|_timestamp/ };
> facts.to_yaml.sort %>"),
>       }
> 


The to_yaml output should start with a "---\n" line, but if you sort
your list  (BTW: I get an error on ruby 1.9 when I call sort on a
string) you may produce an invalid yaml file if the "---" is not on top
anymore.

-Stefan

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to