On Thursday, September 12, 2013 5:36:35 PM UTC-5, Jeremy Martini
wrote:>
> On my file system, I have a classpath.txt file, which contains a java
> classpath. The classpath contains wildcards, and I need to remove the
> wildcards, and have it expanded out to list out all the .jar files
> individually.
>
> So, instead of classpath.txt containing:
>
> C:/lib1/*;C:/lib2/*
>
>
> I Need:
>
> C:/lib1/file_one.jar;C:/lib1/file_two.jar;C:/lib2/file_three.jar
>
>
>
So you want Puppet to modify the contents of classpath.txt, as opposed to
using the result of the glob expansion somewhere else?
> I already have the Ruby code to do this, I just need to somehow get Puppet
> to run this Ruby code.
>
> I figured I would need to create a custom type, which I''ve called
> "classpath_expander." I would include this type in my manifest
like this:
>
Do yourself a favor and choose a type name that is a noun. That better
reflects the nature of the thing you are naming.
Perhaps "classpath_file" would be appropriate.
>
> classpath_expander { ''expand classpath.txt'':
> path => "C:/temp/classpath.txt"
> }
>
>
> Currently, my type is defined like this:
>
> Puppet::Type.newtype(:classpath_expander) do
> @doc = "Reads the classpass in a file, and expands out any
wildcards."
>
> newparam(:name, :namevar => true) do
> desc ''An arbitrary name used as the identity of the
resource.''
> end
>
> newparam(:path) do
> desc ''The path to the classpath file.''
> end
> end
>
>
>
> But at this point, I''m not sure where to put my Ruby code. All the
> documentation gives examples on how to use the "ensurable"
property;
> however, I''m not sure that makes sense in this case, does it? If
so, what
> would I need for each of the "create", "destroy", and
"exist?" methods?
>
You are missing an essential piece of the puzzle: at least one
"provider"
for your custom type. That''s the bit that does all the work; the type
itself is mostly restricted to defining the supported parameters.
Here are some docs that may help:
http://docs.puppetlabs.com/guides/custom_types.html
http://docs.puppetlabs.com/guides/provider_development.html
http://docs.puppetlabs.com/guides/complete_resource_example.html
John
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to puppet-users+unsubscribe@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.