install7.pp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. # jdk7::instal7
  2. #
  3. # On Linux low entropy can cause certain operations to be very slow.
  4. # Encryption operations need entropy to ensure randomness. Entropy is
  5. # generated by the OS when you use the keyboard, the mouse or the disk.
  6. #
  7. # If an encryption operation is missing entropy it will wait until
  8. # enough is generated.
  9. #
  10. # three options
  11. # use rngd service (this class)
  12. # set java.security in JDK ( jre/lib/security )
  13. # set -Djava.security.egd=file:/dev/./urandom param
  14. #
  15. define jdk7::install7 (
  16. $version = '7u25',
  17. $fullVersion = 'jdk1.7.0_25',
  18. $x64 = true,
  19. $alternativesPriority = 17065,
  20. $downloadDir = '/install',
  21. $urandomJavaFix = true,
  22. $sourcePath = "puppet:///modules/${module_name}/",
  23. ) {
  24. if $x64 == true {
  25. $type = 'x64'
  26. } else {
  27. $type = 'i586'
  28. }
  29. case $::kernel {
  30. Linux : {
  31. $installVersion = 'linux'
  32. $installExtension = '.tar.gz'
  33. $path = '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:'
  34. $user = 'root'
  35. $group = 'root'
  36. }
  37. default : {
  38. fail('Unrecognized operating system, please use it on a Linux host')
  39. }
  40. }
  41. $jdkfile = "jdk-${version}-${installVersion}-${type}${installExtension}"
  42. # set the defaults for Exec
  43. Exec {
  44. path => $path,
  45. user => $user,
  46. }
  47. # set the defaults for File
  48. File {
  49. replace => false,
  50. owner => $user,
  51. group => $group,
  52. mode => 0777,
  53. }
  54. exec { "create ${$downloadDir} directory":
  55. command => "mkdir -p ${$downloadDir}",
  56. unless => "test -d ${$downloadDir}",
  57. }
  58. # check install folder
  59. if !defined(File[$downloadDir]) {
  60. file { $downloadDir:
  61. ensure => directory,
  62. require => Exec["create ${$downloadDir} directory"],
  63. }
  64. }
  65. # download jdk to client
  66. file { "${downloadDir}/${jdkfile}":
  67. ensure => file,
  68. source => "${sourcePath}/${jdkfile}",
  69. require => File[$downloadDir],
  70. }
  71. # install on client
  72. javaexec { "jdkexec ${title} ${version}":
  73. path => $downloadDir,
  74. fullVersion => $fullVersion,
  75. jdkfile => $jdkfile,
  76. alternativesPriority => $alternativesPriority,
  77. user => $user,
  78. group => $group,
  79. require => File["${downloadDir}/${jdkfile}"],
  80. }
  81. if ($urandomJavaFix == true) {
  82. exec { "set urandom ${fullVersion}":
  83. command => "sed -i -e's/securerandom.source=file:\\/dev\\/urandom/securerandom.source=file:\\/dev\\/.\\/urandom/g' /usr/java/${fullVersion}/jre/lib/security/java.security",
  84. unless => "grep '^securerandom.source=file:/dev/./urandom' /usr/java/${fullVersion}/jre/lib/security/java.security",
  85. require => Javaexec["jdkexec ${title} ${version}"],
  86. }
  87. }
  88. }