summaryrefslogtreecommitdiff
path: root/manifests/upgrade_package.pp
blob: 2ce6932dbaa5b1e9ff50919066621d7121145035 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
define apt::upgrade_package ($version = "") {

  if $apt::disable_update == false { 
    include apt::update 
  }

  $version_suffix = $version ? {
    ''       => '',
    'latest' => '',
    default  => "=${version}",
  }

  if !defined(Package['apt-show-versions']) {
    package { 'apt-show-versions':
      ensure => installed,
      require => undef,
    }
  }

  if !defined(Package['dctrl-tools']) {
    package { 'dctrl-tools':
      ensure => installed,
      require => undef,
    }
  }

  exec { "apt-get -q -y -o 'DPkg::Options::=--force-confold' install ${name}${version_suffix}":
    onlyif => [ "grep-status -F Status installed -a -P $name -q", "apt-show-versions -u $name | grep -q upgradeable" ],
    require => $apt::disable_update ? {
      true    => Package['apt-show-versions', 'dctrl-tools'],
      default => [ Exec['apt_updated'], 
                 Package['apt-show-versions', 'dctrl-tools'] ],
    } 
  }

}