1 |
class mirror { |
2 |
class base { |
3 |
$bindir = '/home/mirror/bin' |
4 |
$locksdir = '/home/mirror/locks' |
5 |
file { "$bindir": |
6 |
ensure => directory, |
7 |
owner => root, |
8 |
group => root, |
9 |
mode => 755 |
10 |
} |
11 |
|
12 |
file { "$locksdir": |
13 |
ensure => directory, |
14 |
owner => mirror, |
15 |
group => mirror, |
16 |
mode => 755 |
17 |
} |
18 |
|
19 |
group {"mirror": |
20 |
ensure => present, |
21 |
} |
22 |
|
23 |
user {"mirror": |
24 |
ensure => present, |
25 |
comment => "System user use to run mirror scripts", |
26 |
managehome => true, |
27 |
gid => mirror, |
28 |
shell => "/bin/bash", |
29 |
} |
30 |
} |
31 |
|
32 |
define mirrordir ($remoteurl, $localdir, $rsync_options="-avH --delete") { |
33 |
include base |
34 |
$lockfile = "$locksdir/$name" |
35 |
file { "$localdir": |
36 |
ensure => directory, |
37 |
owner => mirror, |
38 |
group => mirror, |
39 |
mode => 755, |
40 |
} |
41 |
file { "mirror_$name": |
42 |
path => "$bindir/mirror_$name", |
43 |
ensure => present, |
44 |
owner => root, |
45 |
group => root, |
46 |
mode => 755, |
47 |
content => template("mirror/mirrordir"), |
48 |
} |
49 |
|
50 |
cron { "mirror_$name": |
51 |
user => mirror, |
52 |
minute => [0, 10, 20, 30, 40, 50], |
53 |
command => "$bindir/mirror_$name", |
54 |
require => File["mirror_$name"], |
55 |
} |
56 |
} |
57 |
|
58 |
# For main Mageia mirror |
59 |
class main inherits base { |
60 |
file { "update_timestamp": |
61 |
path => "$bindir/update_timestamp", |
62 |
ensure => present, |
63 |
owner => root, |
64 |
group => root, |
65 |
mode => 755, |
66 |
content => template("mirror/update_timestamp") |
67 |
} |
68 |
|
69 |
cron { mirror: |
70 |
user => mirror, |
71 |
hour => 10, |
72 |
minute => 14, |
73 |
command => "$bindir/update_timestamp", |
74 |
require => File["update_timestamp"], |
75 |
} |
76 |
} |
77 |
|
78 |
class mirrorbootstrap inherits base { |
79 |
mirrordir { "bootstrap": |
80 |
remoteurl => "rsync://rsync.$domain.org/bootstrap", |
81 |
localdir => '/distrib/bootstrap', |
82 |
} |
83 |
} |
84 |
|
85 |
class mirrormageia inherits base { |
86 |
mirrordir { "mageia": |
87 |
remoteurl => "rsync://rsync.$domain/mageia", |
88 |
localdir => '/distrib/mageia', |
89 |
} |
90 |
} |
91 |
} |