For readability of my *.pp files I use extra white space in template
strings, but the only way I can do this with the augeas provider is to
change the data.split line to strip the white space and blank lines.

Example puppet definition:

define nfs_export($client='*', $options=['ro','sync']) {

    $exports_template = "
        set \"/dir[.='<%= name %>']\" <%= name %>
        set \"/dir[.='<%= name %>']/client[.='<%= client %>']\" <%= client %>
        remove \"/dir[.='<%= name %>']/client[.='<%= client %>']/option\"
        <% options.each do |option| %>set \"/dir[.='<%= name
%>']/client[.='<%= client %>']/option[.='<%= option %>']\" <%= option
%>
        <% end %>"

    include nfs_server

    file {
        $name:
            ensure => directory,
            owner => root,
            group => root,
            mode => 755,
    }

    augeas {
        "exports_${name}":
            context => "/files/etc/exports",
            changes => inline_template($exports_template),
            require => File[$name],
            notify => Service['nfs-kernel-server'],
    }
}


I am not a proficient with ruby though and am unsure of the
performance hit or style guide for these things. I have been using
this in production for a couple of months now with good results. Any
suggestions or problems with the change? Or is this something I will
have to patch for myself each time?

Regards,
Karl Bowden

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb
index d1408d1..f9f2dc4 100644
--- a/lib/puppet/provider/augeas/augeas.rb
+++ b/lib/puppet/provider/augeas/augeas.rb
@@ -62,7 +62,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do
         end
 
         if data.is_a?(String)
-            data = data.split($/)
+            data = data.split(/\s*$\s*/).select {|n|n and n =~ /\w/}
         end
         args = []
         data.each do |line|

Reply via email to