urandomfix.pp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # wls::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 wls::urandomfix() {
  16. case $operatingsystem {
  17. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES: {
  18. $path = '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:'
  19. }
  20. default: {
  21. fail("Unrecognized operating system")
  22. }
  23. }
  24. package { "rng-tools":
  25. ensure => present,
  26. }
  27. case $operatingsystem {
  28. CentOS, RedHat, OracleLinux: {
  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. user => 'root',
  34. path => $path,
  35. }
  36. service { "start rngd service":
  37. name => "rngd",
  38. enable => true,
  39. ensure => true,
  40. require => Exec ["set urandom /etc/sysconfig/rngd"],
  41. }
  42. exec { "chkconfig rngd":
  43. command => "chkconfig --add rngd",
  44. require => Service["start rngd service"],
  45. user => 'root',
  46. unless => "chkconfig | /bin/grep 'rngd'",
  47. path => $path,
  48. }
  49. }
  50. Ubuntu, Debian, SLES:{
  51. exec { "set urandom /etc/default/rng-tools":
  52. command => "sed -i -e's/#HRNGDEVICE=\\/dev\\/null/HRNGDEVICE=\\/dev\\/urandom/g' /etc/default/rng-tools",
  53. unless => "/bin/grep '^HRNGDEVICE=/dev/urandom' /etc/default/rng-tools",
  54. require => Package["rng-tools"],
  55. user => 'root',
  56. path => $path,
  57. }
  58. service { "start rng-tools service":
  59. name => "rng-tools",
  60. enable => true,
  61. ensure => true,
  62. require => Exec ["set urandom /etc/default/rng-tools"],
  63. }
  64. }
  65. }
  66. }