diff --git a/manifests/init.pp b/manifests/init.pp index e86d9725..ed4e03ac 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -98,45 +98,31 @@ fail("The JDK is currently unsupported for Windows via Puppet") } + $sysdrive = $java::params::sysdrive $bundleId = $java::params::java[$distribution]['package'] - - $tempdir = inline_template("<%= ENV['TEMP'] -%>") - $systemdrive = inline_template("<%= ENV['SystemDrive'] -%>") - - $jre_file = "${tempdir}\\java_install.exe" + $jre_file = ".\java_install.exe" $bundle_url = "http://javadl.sun.com/webapps/download/AutoDL?BundleId=${bundleId}" exec { 'download_java': command => "powershell -NoProfile -ExecutionPolicy remotesigned -command \"(new-object net.webclient).DownloadFile('${bundle_url}', '${jre_file}')\"", - path => "${systemdrive}\\windows\\system32;${systemdrive}\\windows\\system32\\WindowsPowerShell\\v1.0", + path => "${sysdrive}\\windows\\system32;${sysdrive}\\windows\\system32\\WindowsPowerShell\\v1.0", unless => "cmd.exe /c If NOT EXIST ${jre_file} Exit 1", } # - # If we are running on the Server Hyper-V release, do not install - # the Java Web plugins. + # We should check if we are running on Hyper-V server. If yes, then + # do not install the Java Web components, other wise, we probably should... # - # if 'ServerHyper' in $java::params::editionInfo { - $web_java = 'WEB_JAVA=0' - # } else { - # $web_java = 'WEB_JAVA=1' - # } + $web_java = 'WEB_JAVA=0' exec { 'install_jre': command => "cmd /c \"${jre_file} /s ${web_java}\"", - path => "${systemdrive}\\windows\\system32;${systemdrive}\\windows\\system32\\WindowsPowerShell\\v1.0", + path => "${sysdrive}\\windows\\system32;${sysdrive}\\windows\\system32\\WindowsPowerShell\\v1.0", require => Exec[ 'download_java' ], unless => "cmd.exe /c If NOT EXIST \"${java::params::java_root_dir}\" Exit 1", } - exec { 'symlink_java': - command => "cmd /c mklink /d \\ProgramData\\Java \"${java::params::java_root_dir}\"", - path => "${systemdrive}\\windows\\system32", - require => Exec[ 'install_jre' ], - unless => 'cmd.exe /c If NOT EXIST \ProgramData\Java Exit 1', - } - - Exec['download_java'] -> Exec['install_jre'] -> Exec['symlink_java'] + Exec['download_java'] -> Exec['install_jre']] } } } diff --git a/manifests/params.pp b/manifests/params.pp index 0d3c2103..508cceb1 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -123,42 +123,30 @@ } 'windows': { # - # Puppet for Windows includes a 32 version of Ruby. A 32 bit Windows - # process will always return a PROCESSOR_ARCHITECTURE of x86, even - # when running on 64 bit hardware. The following code checks the - # registry for the true PROCESSOR_ARCHITECTURE. + # Determine the system drive # - $regInfo = inline_template("<%= `reg.exe query \"HKLM\\\\SYSTEM\\\\CurrentControlSet\\\\Control\\\\Session Manager\\\\Environment\" /v PROCESSOR_ARCHITECTURE` -%>") - if 'AMD64' in $regInfo { - $hw_arch = 'AMD64' - } else { - $hw_arch = 'x86' - } + $temp = split($::env_windows_installdir, '\\') + $sysdrive = $temp[0] # - # We do not want Java to install the WEB plugins on the Server Hyper-V - # release of Windows Server. Collect the Windows Edition from the - # registry so init.pp can decide if the Web plugins should be installed. + # On x64 based system, Java will be installed in "\Program Files", on x86, and the default + # install Java into "\Program Files (x86)" # - $editionInfo = inline_template("<%= `reg.exe query \"HKLM\\\\SOFTWARE\\\\Microsoft\\\\Windows NT\\\\CurrentVersion\" /v EditionID` -%>") - - $systemdrive = inline_template("<%= ENV['SystemDrive'] -%>") - - case $hw_arch { - 'AMD64': { + case $::architecture { + 'x64': { $jdk_package = 'undef' $jre_package = '81821' - $java_root_dir = "${systemdrive}\\Program Files\\Java" + $java_root_dir = "${sysdrive}\\Program Files\\Java" } 'x86': { $jdk_package = 'undef' $jre_package = '81819' - $java_root_dir = "${systemdrive}\\Program Files (x86)\\Java" + $java_root_dir = "${sysdrive}\\Program Files (x86)\\Java" } default: { $jdk_package = 'undef' $jre_package = '81819' - $java_root_dir = "${systemdrive}\\Program Files (x86)\\Java" + $java_root_dir = "${sysdrive}\\Program Files (x86)\\Java" } } $java = {