Skip to content

Instantly share code, notes, and snippets.

@adamhjk
Created September 26, 2008 20:14
Show Gist options
  • Save adamhjk/13193 to your computer and use it in GitHub Desktop.
Save adamhjk/13193 to your computer and use it in GitHub Desktop.
Java preseeding recipe
class java {
case $lsbdistid {
CentOS: { }
default: {
case $lsbdistid {
Debian: {
case $lsbdistcodename {
etch: {
$javasdk = "sun-java5-jdk"
$alternative = "java-5-sun"
}
default: {
$javasdk = "sun-java6-jdk"
$alternative = "java-6-sun"
}
}
}
default: {
$javasdk = "sun-java6-jdk"
$alternative = "java-6-sun"
}
}
seed_package { $javasdk:
ensure => installed,
module => java,
}
package { "ant":
ensure => installed,
require => Seed_package[$javasdk]
}
exec { "update-java-alternatives":
path => "/usr/bin:/bin:/sbin:/usr/sbin",
command => "update-java-alternatives -s $alternative",
refreshonly => true
}
}
}
}
define seed_package($ensure = latest, $module) {
$filedist = "$lsbdistid-$lsbdistrelease"
$seedpath = "/var/cache/local/preseeding"
file { "$seedpath/$name.seed":
path => "$seedpath/${name}.seed",
source => [
"puppet://$puppet_server/seeds/$module/$filedist/$name.seed",
"puppet://$puppet_server/seeds/$module/$lsbdistid/$name.seed",
"puppet://$puppet_server/seeds/$module/default/$name.seed",
"puppet://$puppet_server/$module/seeds/$filedist/$name.seed",
"puppet://$puppet_server/$module/seeds/$lsbdistid/$name.seed",
"puppet://$puppet_server/$module/seeds/default/$name.seed"
],
mode => 0600,
owner => root,
group => root,
}
package { $name:
ensure => $ensure,
responsefile => "$seedpath/$name.seed",
require => File["$seedpath/$name.seed"],
}
}
# Just make sure you have the preseed saving directory handy in some recipe
file { "/var/cache/local":
ensure => "directory",
group => "root",
owner => "root",
mode => 644,
}
file { "/var/cache/local/preseeding":
ensure => "directory",
group => "root",
owner => "root",
mode => 644,
require => File["/var/cache/local"]
}
sun-java6-bin shared/accepted-sun-dlj-v1-1 boolean true
sun-java6-jdk shared/accepted-sun-dlj-v1-1 boolean true
sun-java6-jre shared/accepted-sun-dlj-v1-1 boolean true
sun-java6-jre sun-java6-jre/stopthread boolean true
sun-java6-jre sun-java6-jre/jcepolicy note
sun-java6-bin shared/error-sun-dlj-v1-1 error
sun-java6-jdk shared/error-sun-dlj-v1-1 error
sun-java6-jre shared/error-sun-dlj-v1-1 error
sun-java6-bin shared/present-sun-dlj-v1-1 note
sun-java6-jdk shared/present-sun-dlj-v1-1 note
sun-java6-jre shared/present-sun-dlj-v1-1 note
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment