fatmcgav / fatmcgav-glassfish

Rewritten Glassfish module to improve functionality and support.
http://github.com/fatmcgav/fatmcgav-glassfish
GNU General Public License v3.0
6 stars 31 forks source link

Duplicate declaration of lib/ext when using `glassfish::install_jars` more than once #55

Closed PeterParker closed 8 years ago

PeterParker commented 8 years ago

Consider the following manifest excerpt, which uses the glassfish::install_jars define more than once to specify the "installation" of two jars:

glassfish::install_jars { 'my.jar':
  source => 'puppet:///modules/mymodule/my.jar',
}
glassfish::install_jars { 'myother.jar':
  source => 'puppet:///modules/mymodule/myother.jar',
}

This will result in the following compilation error:

Evaluation Error: Error while evaluating a Resource Statement, Duplicate declaration:
File[/usr/local/glassfish-4.0/glassfish/lib/ext] is already declared in file
/[...]/modules/glassfish/manifests/install_jars.pp:84; cannot redeclare at
/[...]/modules/glassfish/manifests/install_jars.pp:84 at
/[...]/modules/glassfish/manifests/install_jars.pp:84:5 on node [...]

Proposed solution is to give the problematic file resource an explicit title rather than use the directory name, one which will be unique to every separate install_jar define. The directory path would then have to be moved to path attribute instead.

Current Workaround

My use case in this instance is one where I can do without one jar if the other is installed using a simple if else statement, but others may not be so lucky.

fatmcgav commented 8 years ago

@PeterParker I've just created a bug fix branch (fix_55) that should fix this.

Do you want to give it a spin and let me know?

Cheers Gavin

PeterParker commented 8 years ago

@fatmcgav -- Unfortunately I'm still seeing the following:

Error: Evaluation Error: Error while evaluating a Resource Statement, Cannot alias File[mysql-connector-java-5.1.36-bin.jar_lib_ext] to ["/usr/local/glassfish-4.0/glassfish/lib/ext"] at /tmp/vagrant-puppet/modules-4fce94448e73ff14a4caeab031861abd/glassfish/manifests/install_jars.pp:84; resource ["File", "/usr/local/glassfish-4.0/glassfish/lib/ext"] already declared at /tmp/vagrant-puppet/modules-4fce94448e73ff14a4caeab031861abd/glassfish/manifests/install_jars.pp:84 at /tmp/vagrant-puppet/modules-4fce94448e73ff14a4caeab031861abd/glassfish/manifests/install_jars.pp:84:5 on node [...]

Which makes sense now I think about it. The alias is only that -- an alias. Puppet is still always going to try and disallow the declaration of two resources that manage the same underlying resource. I guess File is simultaneously clever enough to work out that the same directory is being managed in both instances, but also dumb enough to not realize the declarations do not contradict each other!

Sorry for leading you down the wrong path on this one.

fatmcgav commented 8 years ago

@PeterParker Ah, yeh... Have hit that scenario before... OK, lets see if I can come up with an alternative...

fatmcgav commented 8 years ago

@PeterParker I've switched to using ensure_resource, do you want to see if that works?

Need to get a local test working for this aswell :)

PeterParker commented 8 years ago

@fatmcgav Sure thing. Trying to find the commit, though. Did you push?

fatmcgav commented 8 years ago

Yep, it should be on the fix_55 branch... a6552211efc84e3d73f82f514c95ecc777912115

I reverted the previous changes aswell, so might just be worth pulling the branch...

PeterParker commented 8 years ago

@fatmcgav Yep, works for me now. I tried with two jars and both are present when I ssh onto my box.

Many thanks for taking a look at this.

fatmcgav commented 8 years ago

@PeterParker Cool, cheers for confirming.

Will get it tidied up and merged in...

PeterParker commented 8 years ago

:+1: