Hello Everyone,
I've implemented a custom type and provider to generate a file, but am
having some trouble with getting it to work right. Googling, reading the
docs and searching the group here haven't led to a solution, so I decided
to ask for help.
As I said I've created a custom type and provided, it's purpose is to
generate a site specific Oracle tnsnames.ora. It allows you to specify a
fully qualified path and an array of Oracle databases. As is, it works, but
only during the "first" puppet run. If I make changes to either the path,
or list of Oracle databases, the file doesn't get updated. Can anyone tell
me what I'm doing wrong, or point me in the right direction? Any help will
be appreciated.
Thanx, Michael
The type is implemented as follows:
Puppet::Type.newtype(:tnsnames) do
ensurable
newparam(:path) do
isnamevar
validate do |value|
raise ArgumentError, "Empty values are not allowed" if value == ""
end
end
newparam(:dbnames, :array_matching => :all) do
validate do |value|
raise ArgumentError, "Empty values are not allowed" if value == ""
end
end
end
The provider looks like this:
require 'fileutils'
Puppet::Type.type(:tnsnames).provide(:tnsnames) do
def create
tnsnames_content=""
# code to fill tnsnames_content deleted to protect the innocent
begin
if tnsnames_content != "":
FileUtils.rm_rf resource[:path]
f = File.new(resource[:path], 'w')
f.write(tnsnames_content)
f.close()
end
rescue Puppet::ExecutionFailure => detail
raise Puppet::Error, "Could not create tnsnames file: #{detail}"
end
end
def destroy
FileUtils.rm_rf resource[:path]
end
def exists?
File.file? resource[:path]
end
end
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/puppet-users/-/HfWXn2DEBlwJ.
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.