summaryrefslogtreecommitdiff
path: root/manifests/package.pp
blob: 159d6930ba8a3667a2d8aa372adab7dec30a3c50 (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
# Install a package with a preseed file to automatically answer some questions.
define apt::package (
  $ensure  = 'present',
  $seedfile_content = '',
  $pin = '',
  $pin_priority = 1000
) {

  $seedfile = "/var/cache/local/preseeding/${name}.seeds"
  $real_seedfile_content = $seedfile_content ? {
    ''      => template ( "site_apt/${::debian_codename}/${name}.seeds" ),
    default => $seedfile_content,
  }

  file { $seedfile:
    content => $real_seedfile_content,
    mode    => '0600',
    owner   => 'root',
    group   => 0,
  }

  if $pin {
    apt::preferences_snippet { $name:
      ensure   => $ensure,
      priority => $pin_priority,
      pin      => $pin,
    }
  }

  package { $name:
    ensure       => $ensure,
    responsefile => $seedfile,
    require      => [File[$seedfile], Apt::Preferences_snippet[$name]],
  }
}