forked from saz/puppet-reprepro
-
Notifications
You must be signed in to change notification settings - Fork 25
/
distribution.pp
115 lines (101 loc) · 3.22 KB
/
distribution.pp
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
== Definition: reprepro::distribution
Adds a "Distribution" to manage.
Parameters:
- *ensure* present/absent, defaults to present
- *basedir* reprepro basedir
- *repository*: the name of the distribution
- *origin*: package origin
- *label*: package label
- *suite*: package suite
- *architectures*: available architectures
- *components*: available components
- *description*: a short description
- *sign_with*: email of the gpg key
- *deb_indices*: file name and compression
- *dsc_indices*: file name and compression
- *update*: update policy name
- *uploaders*: who is allowed to upload packages
- *install_cron*: install cron job to automatically include new packages
- *not_automatic*: automatic pined to 1 by using NotAutomatic, value are "yes" or "no"
Requires:
- Class["reprepro"]
Example usage:
reprepro::distribution {"lenny":
ensure => present,
repository => "my-repository",
origin => "Camptocamp",
label => "Camptocamp",
suite => "stable",
architectures => "i386 amd64 source",
components => "main contrib non-free",
description => "A simple example of repository distribution",
sign_with => "packages@camptocamp.com",
}
*/
define reprepro::distribution (
$repository,
$origin,
$label,
$suite,
$architectures,
$components,
$description,
$sign_with,
$codename = $name,
$ensure = present,
$basedir = $::reprepro::params::basedir,
$udebcomponents = $components,
$deb_indices = 'Packages Release .gz .bz2',
$dsc_indices = 'Sources Release .gz .bz2',
$update = '',
$uploaders = '',
$install_cron = true,
$not_automatic = 'yes'
) {
include reprepro::params
include concat::setup
$notify = $ensure ? {
present => Exec["export distribution ${name}"],
default => undef,
}
concat::fragment { "distribution-${name}":
ensure => $ensure,
target => "${basedir}/${repository}/conf/distributions",
content => template('reprepro/distribution.erb'),
notify => $notify,
}
exec {"export distribution ${name}":
command => "su -c 'reprepro -b ${basedir}/${repository} export ${codename}' reprepro",
path => ['/bin', '/usr/bin'],
refreshonly => true,
logoutput => on_failure,
require => [
User['reprepro'],
Reprepro::Repository[$repository]
],
}
# Configure system for automatically adding packages
file { "${basedir}/${repository}/tmp/${name}":
ensure => directory,
mode => '0755',
owner => $::reprepro::params::user_name,
group => $::reprepro::params::group_name,
}
if $install_cron {
cron { "${name} cron":
command => "cd ${basedir}/${repository}/tmp/${name}; ls *.deb 2>/dev/null; if [ $? -eq 0 ]; then /usr/bin/reprepro -b ${basedir}/${repository} includedeb ${suite} *.deb; rm *.deb; fi",
user => $::reprepro::params::user_name,
environment => "SHELL=/bin/bash",
minute => '*/5',
}
}
if $update {
concat { "${basedir}/${repository}/conf/updates":
owner => $::reprepro::params::user_name,
group => $::reprepro::params::group_name,
mode => '0640',
require => File["${basedir}/${repository}/conf"],
}
}
}