Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup Windows specific code. #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 8 additions & 22 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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']]
}
}
}
32 changes: 10 additions & 22 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down