unattended_upgrades.pp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # Class: apt::unattended_upgrades
  2. #
  3. # This class manages the unattended-upgrades package and related configuration
  4. # files for ubuntu
  5. #
  6. # origins are the repositories to automatically upgrade included packages
  7. # blacklist is a list of packages to not automatically upgrade
  8. # update is how often to run "apt-get update" in days
  9. # download is how often to run "apt-get upgrade --download-only" in days
  10. # upgrade is how often to upgrade packages included in the origins list in days
  11. # autoclean is how often to run "apt-get autoclean" in days
  12. #
  13. # information on the other options can be found in the 50unattended-upgrades
  14. # file and in /etc/cron.daily/apt
  15. #
  16. class apt::unattended_upgrades (
  17. $origins = $::apt::params::origins,
  18. $blacklist = [],
  19. $update = '1',
  20. $download = '1',
  21. $upgrade = '1',
  22. $autoclean = '7',
  23. $auto_fix = true,
  24. $minimal_steps = false,
  25. $install_on_shutdown = false,
  26. $mail_to = 'NONE',
  27. $mail_only_on_error = false,
  28. $remove_unused = true,
  29. $auto_reboot = false,
  30. $dl_limit = 'NONE',
  31. $randomsleep = undef,
  32. $enable = '1',
  33. $backup_interval = '0',
  34. $backup_level = '3',
  35. $max_age = '0',
  36. $min_age = '0',
  37. $max_size = '0',
  38. $download_delta = '0',
  39. $verbose = '0',
  40. ) inherits ::apt::params {
  41. validate_bool(
  42. $auto_fix,
  43. $minimal_steps,
  44. $install_on_shutdown,
  45. $mail_only_on_error,
  46. $remove_unused,
  47. $auto_reboot
  48. )
  49. validate_array($origins)
  50. if $randomsleep {
  51. unless is_numeric($randomsleep) {
  52. fail('randomsleep must be numeric')
  53. }
  54. }
  55. package { 'unattended-upgrades':
  56. ensure => present,
  57. }
  58. file { '/etc/apt/apt.conf.d/50unattended-upgrades':
  59. ensure => file,
  60. owner => 'root',
  61. group => 'root',
  62. mode => '0644',
  63. content => template('apt/50unattended-upgrades.erb'),
  64. require => Package['unattended-upgrades'],
  65. }
  66. file { '/etc/apt/apt.conf.d/10periodic':
  67. ensure => file,
  68. owner => 'root',
  69. group => 'root',
  70. mode => '0644',
  71. content => template('apt/10periodic.erb'),
  72. require => Package['unattended-upgrades'],
  73. }
  74. }