Puppet - Remove ALL versions of Java from PATH -
i attempting remove version of java windows path via puppet.
replace %java_home%\bin.
here current code:
include windows_path define obsolete_java { windows_path { $name: ensure => absent, directory => "c:\\program files\\java\\$name\\bin"; } } define windows_java::setup ( $ensure = 'present', $source = undef, $file = undef, $package = undef ) { case $::osfamily { windows : { $supported = true } default : { fail("the ${module_name} module not supported on ${::osfamily} based systems") } } # validate parameters if ($source == undef) { fail('source parameter must set') } if ($file == undef) { fail('file parameter must set') } if ($package == undef) { fail('package parameter must set') } # validate input values $ensure if !($ensure in ['present', 'absent']) { fail('ensure must either present or absent') } if ($caller_module_name == undef) { $mod_name = $module_name } else { $mod_name = $caller_module_name } if ($ensure == 'present'){ # ensures main directory exists file {'c:\program files\java': ensure => directory, } # copies source executable on file { "c:\\program files\\java\\$source": ensure => present, source => "puppet:///extra_files/java/windows/$source", before => package["$package"], source_permissions => ignore, } # name of package must match name when installed package { "$package": ensure => installed, source => "c:\\program files\\java\\$source", install_options => '/s', } # sets java_home. if existant, replaces it. windows_env { "java_home=c:\\program files\\java\\$file": mergemode => clobber, } # removes previous java path obsolete_java {'jdk1.7.0_51':} # adds java_home path. windows_path {'javapath': ensure => present, directory => "%java_path%\bin", } } else { package { 'remove-package': name => "$package", ensure => absent, } windows_env { 'java_home': ensure => 'absent', mergemode => clobber, } windows_path {'remove_java_path': ensure => absent, directory => "c:\\program files\\java\\$file\\bin", } } }
specifically:
define obsolete_java { windows_path { $name: ensure => absent, directory => "c:\\program files\\java\\$name\\bin"; } }
called here:
# removes previous java path obsolete_java {'jdk1.7.0_51':}
is possible have remove finds under: c:\program files\java\any_jdk bin ?
edit: more importantly, can force find directory contains word "java" , remove path?
seeing windows_path
type complex, there seems no conceivable way provider prefetch full list of existing paths. therefor unable purge
java paths.
that leaves 1 option can see: create external fact (or plain custom fact) retrieve list of directories in path
. if don't use facter 2, need delimited path
string , process on master. facter 2 can hand array master.
if have them in variable, $path_list
, can hand them similar defined type 1 using already.
filter_path { $path_list: } define filter_path { if $name =~ /java/ { windows_path { $name: ensure => absent, directory => $name } } }
Comments
Post a Comment