Defined Type: apt::pin

Defined in:
manifests/pin.pp

Overview

Define: apt::pin

Pinning packages See man apt_preferences for more details

Parameters

package

Name of the package, or array of names. If empty, defaults to $name. If you want to specify two or more pins for the same resource, you can use it, like this:

apt::pin { 'firefox_intrepid':
  package  => 'firefox',
  type     => 'release',
  value    => 'intrepid',
  priority => "900",
}
apt::pin { 'firefox-4.5':
  package  => 'firefox',
  type     => 'version',
  value    => '4.5.*',
  priority => "501",
}
version

Format:

version => '4.5.*',

can be specified as a shorthand for:

type     => 'version',
value    => '4.5.*',
release

Format:

release => 'intrepid',

can be specified as a shorthand for:

type     => 'release',
value    => 'intrepid',
origin

Format:

origin => 'ftp.debian.org',

can be specified as a shorthand for:

type     => 'origin',
value    => 'ftp.debian.org',
type

One of the available pin types: origin, version or release If none of the shorthands nor type is specified, defaults to [version].

value

The value to pin to. Depends on the choosen type. If none specified, defaults to “*”. IE:

type  => 'version'
value => '5.8*'

type  => 'release'
value => 'a=stable, v=7.0'
priority

Priority of the configuration to add

template

Custom template to use, instead of the default one

ensure

Whether to add or delete this pin

suffix

Suffix of the prefs file created, on some distribution it must be .pref

Examples

Usage: Short form: You need to set at least version, release or origin to pin. Can’t specify more than one.

apt::pin { "packageName":
  version  => "version to pin (optional)",
  release  => "release to pin (optional)",
  origin   => "origin  to pin (optional)",
  priority => "pin priority",

Complete form: You need to set at least a value, in which case pin type defaults to “version”

apt::pin { "packageName":
  type     => 'pin_type',
  value    => 'pin criteria',
  priority => 'pin priority',
}

You can provide also a custom template and populate it as you want:

apt::pin { "cassandra":
  template => 'my_site/apt/pin.erb',
}

For example, to forcing installation of cassandra 0.7.5, you can pin it:

apt::pin { 'cassandra':
  type     => 'version',
  value    => '0.7.5',
  priority => '1001',
}

Or, you can force installation of firefox from the intrepid release

apt::pin { 'firefox-3.0':
  type     => 'release',
  value    => 'intrepid',
  priority => "900",
}

Alternatively can provide a custom template and populate it as you want:

apt::pin { "cassandra":
  template => 'my_site/apt/pin.erb',
}

Parameters:

  • package (Any) (defaults to: '')
  • type (Any) (defaults to: '')
  • value (Any) (defaults to: '')
  • priority (Any) (defaults to: '')
  • template (Any) (defaults to: '')
  • version (Any) (defaults to: '')
  • release (Any) (defaults to: '')
  • origin (Any) (defaults to: '')
  • ensure (Any) (defaults to: 'present')
  • suffix (Any) (defaults to: '')


123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'manifests/pin.pp', line 123

define apt::pin (
  $package  = '',
  $type     = '',
  $value    = '',
  $priority = '',
  $template = '',
  $version  = '',
  $release  = '',
  $origin   = '',
  $ensure   = 'present',
  $suffix   = ''
) {

  include apt

  $real_package = $package ? {
    ''      => $name,
    default => $package,
  }

  ### Handle shorthands
  if $origin != '' {
    $real_type = 'origin'
    $real_value = $origin
  }

  if $release != '' {
    $real_type = 'release'
    $real_value = $release
  }

  if $version != '' {
    $real_type = 'version'
    $real_value = $version
  }

  # If no shorthand succeded, we evaluate $type and $value
  if $origin == '' and $release == '' and $version == '' { # i.e. $real_type == undef
    $real_type = $type ? {
      ''      => 'version',
      default => $type,
    }
  }

  if $origin == '' and $release == '' and $version == '' { # i.e. $real_value == undef
    $real_value = $value ? {
      ''      => '*',
      default => $value,
    }
  }

  $manage_file_content = $template ? {
    ''        => 'apt/pin.erb',
    default   => $template,
  }

  file { "apt_pin_${name}":
    ensure  => $ensure,
    path    => "${apt::preferences_dir}/pin-${name}-${real_type}${suffix}",
    mode    => $apt::config_file_mode,
    owner   => $apt::config_file_owner,
    group   => $apt::config_file_group,
    require => Package[$apt::package],
    notify  => Exec['aptget_update'],
    content => template($manage_file_content),
    audit   => $apt::manage_audit,
  }
}