On Thursday, November 29, 2012 5:17:43 PM UTC-5, jcbollinger wrote:
Alternatively, if your approach is going to be to fiddle with the 'source' parameter then you might consider how to avoid subclassing at all.
Agreed. This is what I am focusing on. But have hit a snag I don't know how to resolve. My end goal is to have a patching mechanism for a JEE container that does not have an installer. Just a directory of files that gets copied to the node. I have verified that passing an array with source directories of the patches before the JEE container files works perfectly. I can add patches and roll them back easily. This all works great when I hard code the patch directories in an array before the jee container source directory. However I don't know when a patch will be released and I need the flexibility to apply the patch to only certain nodes. This means the array set for the source has to be created dynamically. I am using a template to create the array from the patches passed in as parameters.
class jee ($patches = []){
...
file {$install_dir:
ensure => directory,
source => split(template('jee/source.erb'),','),
sourceselect => 'all'
recurse => true,
...
}
}
Everything in mind tells me this should work. However when I try to run the above code I get the following error.
"Error: /Stage[main]/jee/File[/usr/local/jee]: Failed to generate additional resources using 'eval_generate: wrong header line format"
I have seen the "wrong header line format" before and it is usually an incorrect quotation someplace. However in this case I am relying on the split function to transform the string returned from the template into an array. I am not sure where to begin debugging this. Any ideas?
One way would be to load your source(s) via hiera. Another might leverage File's behavior of skipping sources that don't exist: for example, if one or more of your sources are declared in terms of the $hostname fact, then you can create hostname-based overrides entirely within your source data for only the nodes you want
I'm not too keen on the $hostname solution. I feel that is what nodes are for so don't want to obfuscate how files get applied by creating another means to do the same thing. Plus this would become a management nightmare given the use case I described earlier.