Re: [Puppet Users] Setting up Java on Windows

1,081 views
Skip to first unread message

Matthew Burgess

unread,
Oct 16, 2012, 9:14:11 AM10/16/12
to puppet...@googlegroups.com
On Tue, Oct 16, 2012 at 5:45 AM, wukong <wicked...@gmail.com> wrote:

> Also is there a way to do this as silent install?
>
> Here is my manifest.
>
> package {"java" :
> ensure => installed,
> provider => "windows",
> source => "C:/Manifests/installables/jdk-6u35-windows-i586.exe",
> }

Launching that .exe will always give you a GUI, unless you provide
some additional arguments. To install the JRE silently, see the
following: http://www.oracle.com/technetwork/java/javase/silent-136552.html#running.

Regards,

Matt.

Josh Cooper

unread,
Oct 16, 2012, 2:08:10 PM10/16/12
to puppet...@googlegroups.com
> --
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
>

Having done this recently, I'd recommend something like the following:

package { 'Java(TM) 7 Update 5':
ensure => installed,
source => '<path>/jre-7u5-windows-i586.exe',
install_options => [
'/s', '/v/qn" ADDLOCAL=jrecore REBOOT=Suppress JAVAUPDATE=0"'
]
}

Note the name of the package needs to match 'DisplayName' as specified
in the registry and displayed in Add/Remove programs.

As for customizing the PATH, this is filed as
https://projects.puppetlabs.com/issues/16048 and there's some
background information here
https://groups.google.com/forum/?fromgroups=#!topic/puppet-users/68ebrAEUzgQ

Josh

--
Josh Cooper
Developer, Puppet Labs

Corey Osman

unread,
Oct 16, 2012, 4:39:46 PM10/16/12
to puppet...@googlegroups.com
I wasn't aware that you could use the package resource for exe files since it looked like it was limited to msi files.
 
I ended up crafting up this solution using exec resource
 
exec{"jdkinstaller":
  command => "${::installer_dir}/jdk-6u30-windows-i586.exe /s ADDLOCAL=\"ToolsFeature,DemosFeature,SourceFeature\" ",
  creates => 'C:\Program Files\Java\jdk1.6.0_30\bin\javac.exe',
  logoutput => 'true',
 }
 
Still struggling to set the Global PATH variable in a nice way.
 
Corey
On Monday, October 15, 2012 11:45:25 PM UTC-5, wukong wrote:
Hi guys,
I have been trying to bootstrap a windows machine with puppet. I need to install java and setup the JAVA_HOME and add bin to the path variable of windows.
I have tried using the package resource with the jdk setup but everytime I run the manifest puppet opens the setup wizard and waits for me to do something.
Am I doing something wrong or is this the right behavior? Also is there a way to do this as silent install?

Here is my manifest.

package {"java" :
    ensure => installed,
    provider => "windows",
    source => "C:/Manifests/installables/jdk-6u35-windows-i586.exe",
}

Thank you.

Paul Tötterman

unread,
Oct 19, 2012, 6:55:12 AM10/19/12
to puppet...@googlegroups.com
Hi,
 
Still struggling to set the Global PATH variable in a nice way.

I set the path using PowerShell (a script which is deployed and executed by puppet), but I imagine you could do something similar with ruby and the win32 api:

 Function Set-Path {
    Param([Parameter(Mandatory=$true)][string]$component,
          [Parameter(Mandatory=$false)][string]$variable='path',
          [Parameter(Mandatory=$false)][string]$target='Machine')

    $path = [Environment]::GetEnvironmentVariable($variable,
                                                  $target).split(';')

    if ($path -notcontains $component) {
        $path += $component

        [Environment]::SetEnvironmentVariable($variable,
                                              [string]::join(';', $path),
                                              $target)
    }
}

Cheers,
Paul
Reply all
Reply to author
Forward
0 new messages