backports.pp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. class apt::backports (
  2. $location = undef,
  3. $release = undef,
  4. $repos = undef,
  5. $key = undef,
  6. $pin = 200,
  7. ){
  8. if $location {
  9. validate_string($location)
  10. $_location = $location
  11. }
  12. if $release {
  13. validate_string($release)
  14. $_release = $release
  15. }
  16. if $repos {
  17. validate_string($repos)
  18. $_repos = $repos
  19. }
  20. if $key {
  21. unless is_hash($key) {
  22. validate_string($key)
  23. }
  24. $_key = $key
  25. }
  26. if ($::apt::xfacts['lsbdistid'] == 'debian' or $::apt::xfacts['lsbdistid'] == 'ubuntu') {
  27. unless $location {
  28. $_location = $::apt::backports['location']
  29. }
  30. unless $release {
  31. $_release = "${::apt::xfacts['lsbdistcodename']}-backports"
  32. }
  33. unless $repos {
  34. $_repos = $::apt::backports['repos']
  35. }
  36. unless $key {
  37. $_key = $::apt::backports['key']
  38. }
  39. } else {
  40. unless $location and $release and $repos and $key {
  41. fail('If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key')
  42. }
  43. }
  44. if is_hash($pin) {
  45. $_pin = $pin
  46. } elsif is_numeric($pin) or is_string($pin) {
  47. # apt::source defaults to pinning to origin, but we should pin to release
  48. # for backports
  49. $_pin = {
  50. 'priority' => $pin,
  51. 'release' => $_release,
  52. }
  53. } else {
  54. fail('pin must be either a string, number or hash')
  55. }
  56. apt::source { 'backports':
  57. location => $_location,
  58. release => $_release,
  59. repos => $_repos,
  60. key => $_key,
  61. pin => $_pin,
  62. }
  63. }