Ask Your Question

Avoid duplicate declaration errors with roles/profiles

asked 2016-01-26 06:09:05 -0500 gravatar image

updated 2016-01-26 08:48:13 -0500


We use the roles/profiles paradigm, but I'm struggling with a specific case. A certain node has multiple profiles, for example 'jenkins' and 'artifactory'. Both of these require the same Java version, which I had declared like this:

  jdk_oracle::version { $jdk_version :
    system_default => true,

Having it set like this allows other nodes to have multiple versions of java installed (some have 7 and 8). On this particular node, both profiles have the same version. How do other people solve this? I could bring the jdk installation into the role, or a separate profile, but this loses the information that both Jenkins and Artifactory require this particular version. These roles both use other modules to handle the finer grained details of a Jenkins and Artifactory installation, the profile is very site specific.

Regards, Steven

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-01-26 09:09:07 -0500

updated 2016-01-26 10:36:11 -0500

If you can solve the problem by creating a separate JDK profile that would be ideal.

I don't see any issue about losing information because if you are dealing with quirky software that needs a special JDK version, that's something I would be talking about in a comment somewhere anyway. As the maintainer of this code, I would want to know more than just what JDK version app X uses, but also, why can't it use the latest JDK?

Style considerations aside, you may have found a valid use-case for virtual resources:

@jdk_oracle::version { $jdk_version:
  system_default => true,
realize Jdk_oracle::Version

And you can put that in both profiles, and you won't get the duplicate resources.


You can also do this:

    system_default: true
    system_default: false

Then in profile::base:

class profile::base (
) {
  create_resources('jdk_oracle::version', $jdk_oracle_versions)
edit flag offensive delete link more


I don't see how I can put this into a separate profile without losing the ability to define multiple JDK versions on the same machine (unless I add an array/hash parameter?). An example of why I can't use the latest JDK is JBoss EAP 6.1, it refuses to start with JDK8. I have hundreds of JVMs in prod gravatar ( 2016-01-26 09:47:53 -0500 )edit

No you're probably right, which is why I said you may need virtual resources. I always consider that a last resort. I'd be asking, do I need to run both on the same host, or can I spin a second host? Can I find a version of JDK that makes everyone happy etc? I just don't like virtual resources.

Alex Harvey gravatar imageAlex Harvey ( 2016-01-26 10:00:54 -0500 )edit

Me neither, but it does the trick, so flagged the answer as correct. gravatar ( 2016-01-26 10:18:19 -0500 )edit

See my update.

Alex Harvey gravatar imageAlex Harvey ( 2016-01-26 10:36:50 -0500 )edit

I may actually end up doing that (or something similar). It is how we currently roll out all the JBoss instances. gravatar ( 2016-01-26 10:48:47 -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


Asked: 2016-01-26 06:09:05 -0500

Seen: 468 times

Last updated: Jan 26 '16