I'm working on a type/provider for the eucalyptus.conf file. What I
have generally works for modifying properties. I have a couple of
issues and not being very experienced with Ruby and custom providers,
I wonder if anyone can help?
The code is included below. The key/value constructs in the file look like:
key="value"
1. I'm not getting the quotes surrounding the value, which I think I
can figure out myself.
2. I get all blanks and comments replaced by "=", which is more of a problem.
David
require 'puppet/provider/parsedfile'
eucaconf = "/etc/eucalyptus/eucalyptus.conf"
Puppet::Type.type(:eucalyptus_config).provide(
:parsed,
:parent => Puppet::Provider::ParsedFile,
:default_target => eucaconf,
:filetype => :flat
) do
confine :exists => eucaconf
text_line :comment, :match => /^#/;
text_line :blank, :match => /^\s*$/;
record_line :parsed,
:fields => %w{line},
:match => /(.*)/ ,
:post_parse => proc { |hash|
Puppet.debug("eucalyptus config line:#{hash[:line]} has been parsed")
if hash[:line] =~ /^\s*(\S+)\s*=\s*(\S+)\s*$/
hash[:name]=$1
hash[:value]=$2
elsif hash[:line] =~ /^\s*(\S+)\s*$/
hash[:name]=$1
hash[:value]=false
else
raise Puppet::Error, "Invalid line: #{hash[:line]}"
end
}
def self.to_line(hash)
"#{hash[:name]}=#{hash[:value]}"
end
end
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" 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-users?hl=en.