Ask Your Question

Puppet module to update a file content in jar

asked 2017-04-25 09:10:17 -0600

CBR gravatar image


Is there a module to update file content in jars using puppet module ? I'm hardening tomcat binaries based on owasp and would like to know if I have to use exec or some other module available ?

Thank you.

edit retag flag offensive close merge delete


As far as I know, There isn't any 'jar manipulation' modules on the forge. Depending on the file you want to update... Do you have the full file that you want to replace in your module, or are you expecting to 'extract file from jar' -> 'update content in file' -> 'update jar with modified file'?

DarylW gravatar imageDarylW ( 2017-04-25 22:14:58 -0600 )edit

yes. I need to extract -> update content -> update jar.

CBR gravatar imageCBR ( 2017-04-26 05:56:11 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-04-28 03:31:24 -0600

John Ericson gravatar image

updated 2017-05-02 07:48:34 -0600

DarylW gravatar image


I have the same need as you. I solved it by doing a ruby function generate_java_jar that I could use in a file resource. So my final code in Puppet manifest looks like this:

            file { "$install_dir_app_java/lib/properties.jar":
                    ensure => file,
                    content => generate_java_jar(template('my_java_app/'),template('my_java_app/')),

In this ruby function I use shell functions to use the jar command shipped with Java for updating and packaging the jar-file.

edit flag offensive delete link more


I think this holds true if the properties is directly within the first level of jar path. If I want to update in org/apache/catalina/util... I would probably need a custom type and provider. The exec function I'm using is always generating jar even after using onlyif/unless.

CBR gravatar imageCBR ( 2017-05-03 10:33:39 -0600 )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

1 follower


Asked: 2017-04-25 09:10:17 -0600

Seen: 184 times

Last updated: May 02 '17