# Revision history [back]

### Setting parameters in the roles & profiles pattern

TLDR: Is there a way to write reusable profiles, that roles can configure with sane defaults, only overriding using Hiera when required?

I'm following the roles & profiles pattern documented at https://docs.puppet.com/pe/2016.2/r_n_p_intro.html.

"Rule 1" states "Make sure you can safely include any profile multiple times — don’t use resource-like declarations on them.

Like the example, I'm setting up a Jenkins server (but this applies to anything) but I'd like to abstract out some configuration like java and the Apache reverse proxy so I can reuse it in elsewhere as well. So I have:

class profiles::apache_reverse_proxy($context = "/") { // use puppet::apache to configure reverse proxy on$context
}

class profiles::jenkins() {
// configure jenkins only (not apache)
}

class roles::jenkins_master() {
include profiles::base_server
include profiles::java8
include profiles::apache_reverse_proxy  // <-- how to set reverse proxy $context as "/jenkins" include profiles::jenkins } Obviously I could set the$context in Hiera, but I'd like the Jenkisn role to have a sane default configuration (e.g. "/jenkins") that hiera only overrides if needed (e.g. "/jenkins-dev").

Normally I would include the Apache class with

class {'apache_reverse_proxy:
context => '/jenkins'
}