Ask Your Question
2

How to create a simple, custom type?

asked 2013-09-12 17:25:09 -0500

jpm290 gravatar image

updated 2013-09-16 15:26:40 -0500

Stefan gravatar image

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

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 ... (more)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
5

answered 2013-09-13 19:22:45 -0500

Stefan gravatar image

updated 2013-09-13 20:20:46 -0500

This is not really the purpose of a puppet resource. A resource declares the desired value of certain attributes and the provider is there to get the current value and to enforce the desired value.

The problem here is that your desired value (the expanded version of your classpath) is solely dependent on the current value (the - perhaps - unexpanded version of your classpath).

If you really don't know the correct pathnames beforehand and only know the globs I'd suggest the following design:

classpath { 'C:/lib1/*':
  ensure => present,
}
classpath { 'C:/lib2/*':
  ensure => present,
}

You can now write a type ... (more)

edit flag offensive delete link more

Comments

Thanks for your very thorough response, I really appreciate it! I'm still learning how to use Puppet, and you introduced some concepts I haven't yet seen, so it ...(more)

jpm290 gravatar imagejpm290 ( 2013-09-15 07:51:01 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2013-09-12 17:25:09 -0500

Seen: 184 times

Last updated: Sep 16 '13