----- Original Message -----
> From: "Zane Williamson" <zane.william...@gmail.com>
> To: puppet-users@googlegroups.com
> Sent: Friday, December 14, 2012 3:02:13 AM
> Subject: [Puppet Users] Re: Puppet and Mcollective yaml file changing when it 
> shouldn't
> 
> Actually, applying sort doesn't work. It doesn't sort the file
> properly and the spacing and line creation is incorrect.
> 
> I looked at other similar posts and it appears to be an issues with
> Ruby with no direct solution besides stopping puppet from managing
> this file.

yeah, ruby hashes does not have an order in older versions of ruby, this
is quite a horrible hack but some have reported success:

<%=
  def sort_yaml(obj)
    arr = obj.sort
    out = "---\n"
    arr.each do |element|
      entry = {element[0] => element[1]}
      out += entry.to_yaml.to_a[1..-1].join + "\n"
    end
    out
  end

  sort_yaml(scope.to_hash.reject {|k,v| k.to_s =~ 
/^(uptime.*|rubysitedir|_timestamp|memoryfree|extlookup_precedence|extlookup_datadir|swapfree|title|name|caller_module_name|module_name)$/
 })
%>

-- 
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