Ask Your Question
0

Manifest file to automate a .java file

asked 2014-03-03 16:13:06 -0500

Chandra gravatar image

updated 2014-03-03 16:45:53 -0500

Hello, I'm new to puppet labs. I'm trying to learn how to write puppet manifests and automate java applications. So I have started with downloading learning puppet VM , and I have learned some basic commands on creating user and deleting. Now I'm planning to write a java program and automate the compilation and then would like to extend my learning process to automating the deployment of an EAR file in an app server. For this I have installed jdk and have written a simple java program. Now can some one guide me to write a manifest file ... (more)

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2014-03-03 16:47:27 -0500

Michal Bryxí gravatar image

updated 2014-03-04 04:14:58 -0500

First of all: In puppet manifests case matters. I believe you wanted file, not File. See puppet FAQ why.

Your problem can be probably solved by exec type which allows you to call javac for compiling the source. Complete reference for types can be found in puppet type reference.

For serving files via puppet (as used in my example), please read: The puppet file server.

file { '/root/examples/add.java': 
    source => 'puppet:///modules/module_name/add.java', # This is tricky!
    ensure => present, 
    notify => Exec['javac_compile'], # When file changes, run compilation
}
exec { 'javac_compile':
    command => 'javac /root/examples/add.java',
    refreshonly =≥ true, # Runs ...
(more)
edit flag offensive delete link more

Comments

Michal, Thank You very much for responding. This is the error i'm experiencing; Error: Validation of Exec['javac_compile'] failed: 'javac /root/examples/add.java is not qualified and no ...(more)

Chandra gravatar imageChandra ( 2014-03-03 18:03:57 -0500 )edit
1

the problem with that design is that your exec will be executed always, so you should add refreshonly => true or redesign it. Also I believe ensure => running is not a ...(more)

golja gravatar imagegolja ( 2014-03-04 01:19:02 -0500 )edit
1

the error you posted above in your comment is due to the way you're executing java. "Please qualify the command or specify a path" is referring to the 'javac ...(more)

JoshiiSinfield gravatar imageJoshiiSinfield ( 2014-03-04 03:51:56 -0500 )edit

Edited the answer according to golja na JoshiiSinfield remarks. Thanks.

Michal Bryxí gravatar imageMichal Bryxí ( 2014-03-04 04:02:56 -0500 )edit
1

answered 2014-03-03 17:42:32 -0500

lavaman gravatar image

The previous answer has multiple issues. You can't ensure a file is running, and the exec to compile would run every puppet run.

You should, in general, deploy artifacts and not source. Instead of having puppet lay down the java and compile it, you should have it simply push the compiled version (you should be deploying java apps via jars or similar anyway). Then you want proper init scripts for your app and you can then use the service resource to manage running it.

http://docs.puppetlabs.com/references/latest/type.html#service

You would want the jar or ... (more)

edit flag offensive delete link more

Comments

I have compiled the .java file and created a jar file with add.class file. now add.jar is located at /root/examples ; now will the following manifest file suffice ...(more)

Chandra gravatar imageChandra ( 2014-03-03 18:25:27 -0500 )edit

That pushes the jar file out, but you still need the init script and a service resource to manage running the app.

lavaman gravatar imagelavaman ( 2014-03-05 11:17:53 -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

1 follower

Stats

Asked: 2014-03-03 16:13:06 -0500

Seen: 931 times

Last updated: Mar 04 '14