Ask Your Question
0

Make jsrsigner Idiomatic

asked 2014-10-14 00:12:26 -0500

opticyclic gravatar image

I am provisioning a server for a Java Web Start application using vagrant and puppet. As part of that I am signing the jars using

   exec { 'sign jars':
     cwd     => "/home/user/app/jars",
     command => "sudo su - user -c 'cd /home/user/app/jars;find . -iname \"*.jar\" | xargs -i jarsigner -verbose -certs -keystore JAWS.key -storepass user{} app>signing.txt'",
     timeout => 900,
   }

However, if I run vagrant provision after my server is up the jars get signed again even though they are already signed. Is there any way I can make this idiomatic?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-10-14 07:04:43 -0500

rnelson0 gravatar image

I believe that what you are looking for is the exec's creates, onlyif, and unless attributes. As noted here, the command attribute of an exec must be idempotent. There are three ways to do so - the command itself is idempotent, refreshonly is set to true, or through the use of the three listed attributes. It seems likely that you want the creates attribute, like so:

   exec { 'sign jars':
     cwd     => "/home/user/app/jars",
     creates => '/home/user/app/jars/signing.txt',
     command => "sudo su - user -c 'cd /home/user/app/jars;find . -iname \"*.jar\" | xargs -i jarsigner -verbose -certs -keystore JAWS.key -storepass user{} app>signing.txt'",
     timeout => 900,
   }

It may be more appropriate to use unless/onlyif and verify the contents of signing.txt. Check the documentation of the attributes to determine which satisfies your needs the best.

edit flag offensive delete link more

Comments

I only had signing.txt in there for debugging purposes when it wasn't signing properly. I hadn't thought to actually use it in this context! Verifying the contents might be too much for my use case (I might try and do it later anyway), in the mean time I will just check that the file exists. Thanks!

opticyclic gravatar imageopticyclic ( 2014-10-15 22:16:26 -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-10-14 00:12:26 -0500

Seen: 18 times

Last updated: Oct 14 '14