install7.pp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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 = '7u51',
  17. $fullVersion = 'jdk1.7.0_51',
  18. $javaHomes = '/usr/java',
  19. $x64 = true,
  20. $alternativesPriority = 17065,
  21. $downloadDir = '/install',
  22. $cryptographyExtensionFile = undef,
  23. $urandomJavaFix = true,
  24. $rsakeySizeFix = false, # set true for weblogic 12.1.1 and jdk 1.7 > version 40
  25. $sourcePath = "puppet:///modules/jdk7/",
  26. ) {
  27. if ( $x64 == true ) {
  28. $type = 'x64'
  29. } else {
  30. $type = 'i586'
  31. }
  32. case $::kernel {
  33. 'Linux': {
  34. $installVersion = 'linux'
  35. $installExtension = '.tar.gz'
  36. $path = '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:'
  37. $user = 'root'
  38. $group = 'root'
  39. }
  40. default: {
  41. fail("Unrecognized operating system ${::kernel}, please use it on a Linux host")
  42. }
  43. }
  44. $jdkfile = "jdk-${version}-${installVersion}-${type}${installExtension}"
  45. # set the defaults for Exec
  46. Exec {
  47. path => $path,
  48. user => $user,
  49. }
  50. # set the defaults for File
  51. File {
  52. replace => false,
  53. owner => $user,
  54. group => $group,
  55. mode => 0777,
  56. }
  57. exec { "create ${$downloadDir} directory":
  58. command => "mkdir -p ${$downloadDir}",
  59. unless => "test -d ${$downloadDir}",
  60. }
  61. # check install folder
  62. if !defined(File[$downloadDir]) {
  63. file { $downloadDir:
  64. ensure => directory,
  65. require => Exec["create ${$downloadDir} directory"],
  66. }
  67. }
  68. # download jdk to client
  69. file { "${downloadDir}/${jdkfile}":
  70. ensure => file,
  71. source => "${sourcePath}/${jdkfile}",
  72. require => File[$downloadDir],
  73. }
  74. if ( $cryptographyExtensionFile != undef ) {
  75. file { "${downloadDir}/${cryptographyExtensionFile}":
  76. ensure => file,
  77. source => "${sourcePath}/${cryptographyExtensionFile}",
  78. require => File[$downloadDir],
  79. before => File["${downloadDir}/${jdkfile}"],
  80. }
  81. }
  82. # install on client
  83. jdk7::javaexec { "jdkexec ${title} ${version}":
  84. path => $downloadDir,
  85. fullVersion => $fullVersion,
  86. javaHomes => $javaHomes,
  87. jdkfile => $jdkfile,
  88. cryptographyExtensionFile => $cryptographyExtensionFile,
  89. alternativesPriority => $alternativesPriority,
  90. user => $user,
  91. group => $group,
  92. require => File["${downloadDir}/${jdkfile}"],
  93. }
  94. if ($urandomJavaFix == true) {
  95. exec { "set urandom ${fullVersion}":
  96. command => "sed -i -e's/securerandom.source=file:\\/dev\\/urandom/securerandom.source=file:\\/dev\\/.\\/urandom/g' ${javaHomes}/${fullVersion}/jre/lib/security/java.security",
  97. unless => "grep '^securerandom.source=file:/dev/./urandom' ${javaHomes}/${fullVersion}/jre/lib/security/java.security",
  98. require => Javaexec["jdkexec ${title} ${version}"],
  99. }
  100. }
  101. if ($rsakeySizeFix == true) {
  102. exec { "sleep 3 sec for urandomJavaFix ${fullVersion}":
  103. command => "/bin/sleep 3",
  104. unless => "grep 'RSA keySize < 512' ${javaHomes}/${fullVersion}/jre/lib/security/java.security",
  105. require => Javaexec["jdkexec ${title} ${version}"],
  106. }
  107. exec { "set RSA keySize ${fullVersion}":
  108. command => "sed -i -e's/RSA keySize < 1024/RSA keySize < 512/g' ${javaHomes}/${fullVersion}/jre/lib/security/java.security",
  109. unless => "grep 'RSA keySize < 512' ${javaHomes}/${fullVersion}/jre/lib/security/java.security",
  110. subscribe => Exec["sleep 3 sec for urandomJavaFix ${fullVersion}"],
  111. refreshonly => true,
  112. }
  113. }
  114. }