unattended_upgrades.pp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. $legacy_origin = $::apt::params::legacy_origin,
  18. $origins = $::apt::params::origins,
  19. $blacklist = [],
  20. $update = '1',
  21. $download = '1',
  22. $upgrade = '1',
  23. $autoclean = '7',
  24. $auto_fix = true,
  25. $minimal_steps = false,
  26. $install_on_shutdown = false,
  27. $mail_to = 'NONE',
  28. $mail_only_on_error = false,
  29. $remove_unused = true,
  30. $auto_reboot = false,
  31. $dl_limit = 'NONE',
  32. $randomsleep = undef,
  33. $enable = '1',
  34. $backup_interval = '0',
  35. $backup_level = '3',
  36. $max_age = '0',
  37. $min_age = '0',
  38. $max_size = '0',
  39. $download_delta = '0',
  40. $verbose = '0',
  41. ) inherits ::apt::params {
  42. validate_bool(
  43. $legacy_origin,
  44. $auto_fix,
  45. $minimal_steps,
  46. $install_on_shutdown,
  47. $mail_only_on_error,
  48. $remove_unused,
  49. $auto_reboot
  50. )
  51. validate_array($origins)
  52. if $randomsleep {
  53. unless is_numeric($randomsleep) {
  54. fail('randomsleep must be numeric')
  55. }
  56. }
  57. package { 'unattended-upgrades':
  58. ensure => present,
  59. }
  60. file { '/etc/apt/apt.conf.d/50unattended-upgrades':
  61. ensure => file,
  62. owner => 'root',
  63. group => 'root',
  64. mode => '0644',
  65. content => template('apt/_header.erb', 'apt/50unattended-upgrades.erb'),
  66. require => Package['unattended-upgrades'],
  67. }
  68. file { '/etc/apt/apt.conf.d/10periodic':
  69. ensure => file,
  70. owner => 'root',
  71. group => 'root',
  72. mode => '0644',
  73. content => template('apt/_header.erb', 'apt/10periodic.erb'),
  74. require => Package['unattended-upgrades'],
  75. }
  76. }