urandomfix.pp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # jdk7::urandomfix
  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. class jdk7::urandomfix () {
  16. case $::kernel {
  17. Linux : { $path = '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:' }
  18. default : { fail("Unrecognized operating system") }
  19. }
  20. # set the Exec defaults
  21. Exec {
  22. path => $path,
  23. logoutput => true,
  24. user => 'root',
  25. }
  26. package { "rng-tools": ensure => present, }
  27. case $osfamily {
  28. RedHat : {
  29. exec { "set urandom /etc/sysconfig/rngd":
  30. command => "sed -i -e's/EXTRAOPTIONS=\"\"/EXTRAOPTIONS=\"-r \\/dev\\/urandom -o \\/dev\\/random -b\"/g' /etc/sysconfig/rngd",
  31. unless => "/bin/grep '^EXTRAOPTIONS=\"-r /dev/urandom -o /dev/random -b\"' /etc/sysconfig/rngd",
  32. require => Package["rng-tools"],
  33. }
  34. service { "start rngd service":
  35. name => "rngd",
  36. enable => true,
  37. ensure => true,
  38. require => Exec["set urandom /etc/sysconfig/rngd"],
  39. }
  40. exec { "chkconfig rngd":
  41. command => "chkconfig --add rngd",
  42. require => Service["start rngd service"],
  43. unless => "chkconfig | /bin/grep 'rngd'",
  44. }
  45. }
  46. Debian, Suse : {
  47. exec { "set urandom /etc/default/rng-tools":
  48. command => "sed -i -e's/#HRNGDEVICE=\\/dev\\/null/HRNGDEVICE=\\/dev\\/urandom/g' /etc/default/rng-tools",
  49. unless => "/bin/grep '^HRNGDEVICE=/dev/urandom' /etc/default/rng-tools",
  50. require => Package["rng-tools"],
  51. }
  52. service { "start rng-tools service":
  53. name => "rng-tools",
  54. enable => true,
  55. ensure => true,
  56. require => Exec["set urandom /etc/default/rng-tools"],
  57. }
  58. }
  59. }
  60. }