Page MenuHomePhabricator

VM images duplicate /etc/apt/preferences.d/wikimedia{,.pref}
Closed, ResolvedPublic

Description

It looks as if operations/puppet:modules/labs_vmbuilder/files/postinst.copy copies the WMF pinning to /etc/apt/preferences.d/wikimedia.pref. However, /etc/apt/preferences.d/wikimedia is created by operations/puppet:modules/apt/manifests/init.pp with (almost) the same content:

scfc@toolsbeta-mariadb-test5:~$ diff -u /etc/apt/preferences.d/wikimedia{,.pref}
--- /etc/apt/preferences.d/wikimedia 2013-12-18 17:54:53.194063237 +0000
+++ /etc/apt/preferences.d/wikimedia.pref 2012-05-15 19:32:09.923918775 +0000
@@ -1,3 +1,4 @@
+Explanation: Prefer Wikimedia APT repository packages in all cases
Package: *
Pin: release o=Wikimedia
Pin-Priority: 1001
scfc@toolsbeta-mariadb-test5:~$

So (in theory) changes to /etc/apt/preferences.d/wikimedia triggered by operations/puppet:modules/apt/manifests/init.pp might be ineffective as /etc/apt/preferences.d/wikimedia.pref will remain lingering. These should be combined as /etc/apt/preferences.d/wikimedia.


Version: unspecified
Severity: trivial

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 2:35 AM
bzimport added a project: Cloud-VPS.
bzimport set Reference to bz58681.
bzimport added a subscriber: Unknown Object (MLST).

Change 195081 had a related patch set uploaded (by Tim Landscheidt):
Ensure that apt preferences are named *.pref

https://gerrit.wikimedia.org/r/195081

Change 195081 merged by Filippo Giunchedi:
Ensure that apt preferences are named *.pref

https://gerrit.wikimedia.org/r/195081

this has been merged, we can also improve apt::pin to check whether the name will get ignored by apt or not

scfc claimed this task.

The canonical puppetlabs/apt module solves that question by replacing all characters that would cause apt to ignore the file with _:

# According to man 5 apt_preferences:
# The files have either no or "pref" as filename extension
# and only contain alphanumeric, hyphen (-), underscore (_) and period
# (.) characters. Otherwise APT will print a notice that it has ignored a
# file, unless that file matches a pattern in the
# Dir::Ignore-Files-Silently configuration list - in which case it will
# be silently ignored.
$file_name = regsubst($title, '[^0-9a-z\-_\.]', '_', 'IG')

$path = $order ? {
  ''      => "${preferences_d}/${file_name}.pref",
  default => "${preferences_d}/${order}-${file_name}.pref",
}
file { "${file_name}.pref":
  ensure  => $ensure,
  path    => $path,
  owner   => root,
  group   => root,
  mode    => '0644',
  content => template('apt/_header.erb', 'apt/pin.pref.erb'),
}

However rather than amending these manifests piece by piece, for me that would scratch an itch to wholeheartedly replace our home-grown module with Puppet Lab's, but that would mean a lot of work, lots of runs of puppet-compiler, and still a nervous stomach :-). So maybe some time in the future.