How to override attributes with multiple recipes in a wrapper cookbook


#1

Hi, I’m trying to install Java on a Windows PC with a wrapper cookbook for
the ‘java’ cookbook.
I’ve managed to get this working OK, but now I need to install 2 different
versions of Java (32bit and 64bit)
and I wasn’t sure how best to go about this (as I’m new to Chef and just
learning).

I thought I could create another recipe in my wrapper cookbook and override
the attributes I need,
however when I do this only the 64-bit version is getting installed. I
know I could create
another wrapper cookbook to do this, but thought there might be a simpler
way. Is there a way to
do this with a single wrapper cookbook (or even better without any wrapper
cookbooks)?

Here’s what I have so far:

{
“run_list” : [
“recipe[win-java]”,
“recipe[win-java::sixtyfourbit]”,
“recipe[eclipse]”
]
}

win-java is my ‘wrapper’ cookbook


metadata.rb

name 'bar’
maintainer 'YOUR_COMPANY_NAME’
maintainer_email 'YOUR_EMAIL’
license 'All rights reserved’
description 'Installs/Configures bar’
long_description IO.read(File.join(File.dirname(FILE), ‘README.md’))
version '0.1.0’
depends "windows"
depends “java”


attributes.rb

#- The internal location of your java install for windows
default[‘java’][‘windows’][‘url’] =
“file:////clint/documents/CRM/java/JDK/jdk-7u51-windows-i586.exe”

#- The package name used by windows_package to check in the registry to
determine if the install has already been run
default[‘java’][‘windows’][‘package_name’] = ‘Java 7 Update 51’

default[‘java’][‘java_home’] = “C:\dev\Java_32bit\jdk1.7.0_51”


recipes/default.rb

include_recipe “java”


recipes/sixtyfourbit.rb

include_recipe “java”

node.override[‘java’][‘windows’][‘url’] =
“file:////clint/documents/CRM/java/JDK/jdk-7u51-windows-x64.exe”

#- The package name used by windows_package to check in the registry to
determine if the install has already been run
node.override[‘java’][‘windows’][‘package_name’] = ‘Java SE Development Kit
7 Update 51 (64-bit)’

node.override[‘java’][‘java_home’] = “C:\dev\Java_64bit\jdk1.7.0_51”

Thanks, Richard.