tagged.pp 2.14 KB
Newer Older
1
2
3
# Manage tagged snapshots of the set of APT repositories Tails needs,
# in a reprepro setup.
class tails::reprepro::snapshots::tagged (
4
5
6
7
8
  Enum['present', 'absent'] $ensure = 'present',
  Stdlib::Absolutepath $homedir     = '/srv/apt-snapshots/tagged',
  String $email_recipient           = 'root',
  String $user                      = 'reprepro-tagged-snapshots',
  Stdlib::Fqdn $web_hostname        = 'tagged.snapshots.deb.tails.boum.org',
9
  Stdlib::Port $web_port            = 80,
10
) {
11

12
13
  $repositories_dir = "${homedir}/repositories"

14
15
16
17
18
  $package_ensure = $ensure ? {
    absent  => absent,
    default => present,
  }

19
  tails::reprepro::snapshots::base {'tagged':
bertagaz's avatar
Lint.    
bertagaz committed
20
21
    ensure           => $ensure,
    homedir          => $homedir,
22
    repositories_dir => $repositories_dir,
bertagaz's avatar
Lint.    
bertagaz committed
23
    user             => $user,
24
25
  }

intrigeri's avatar
intrigeri committed
26
  $prepare_tagged_snapshot_import_pkg_deps = [
27
28
29
30
    libfile-slurp-perl,
    libyaml-libyaml-perl,
    liblist-compare-perl,
    liblist-moreutils-perl,
31
    libdpkg-perl,
32
  ]
33
  ensure_packages(
intrigeri's avatar
intrigeri committed
34
    $prepare_tagged_snapshot_import_pkg_deps,
35
36
    {'ensure' => $package_ensure}
  )
37
38

  file { '/usr/local/bin/tails-prepare-tagged-apt-snapshot-import':
39
    ensure  => $ensure,
40
41
42
43
    owner   => root,
    group   => root,
    mode    => '0755',
    source  => 'puppet:///modules/tails/reprepro/snapshots/tagged/tails-prepare-tagged-apt-snapshot-import',
intrigeri's avatar
intrigeri committed
44
    require => Package[$prepare_tagged_snapshot_import_pkg_deps],
45
  }
intrigeri's avatar
intrigeri committed
46

47
48
  ensure_packages(['libnginx-mod-http-fancyindex'])

49
  nginx::vhostsd { $web_hostname:
50
    ensure  => $ensure,
51
    content => template('tails/reprepro/snapshots/tagged/nginx_site.erb'),
intrigeri's avatar
Lint.    
intrigeri committed
52
    require => Package[nginx, 'libnginx-mod-http-fancyindex'],
53
  }
54

groente's avatar
groente committed
55
  mailalias { $user:
56
57
    recipient => $email_recipient,
  }
58
59
60
61
62

  # De-duplicate with hardlinks
  ensure_packages(hardlink, {'ensure' => $package_ensure})
  cron { 'deduplicate-tagged-apt-snapshots':
    ensure  => $ensure,
63
    command => "output=\$(hardlink --keep-oldest --ignore-time '${repositories_dir}'); ret=\$?; [ \$ret = 0 ] || printf \"\\%s\" \"\$output\"; exit \$ret", # lint:ignore:140chars -- command
64
65
66
67
68
    hour    => 12,
    minute  => 17,
    user    => $user,
    require => Package[hardlink],
  }
69
}