-
Notifications
You must be signed in to change notification settings - Fork 124
Expand file tree
/
Copy pathserver.pp
More file actions
148 lines (134 loc) · 3.48 KB
/
server.pp
File metadata and controls
148 lines (134 loc) · 3.48 KB
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
116
117
118
119
120
121
122
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
# Class: rsync::server
#
# The rsync server. Supports both standard rsync as well as rsync over ssh
#
# Requires:
# class xinetd if use_xinetd is set to true
# class rsync
#
class rsync::server(
$use_xinetd = true,
$address = '0.0.0.0',
$motd_file = 'UNSET',
$use_chroot = 'yes',
$uid = 'nobody',
$gid = 'nobody',
$nice = '0',
$ionice = '2',
$modules = {},
) inherits rsync {
case $::osfamily {
'Debian': {
$conf_file = '/etc/rsyncd.conf'
$servicename = 'rsync'
case $::operatingsystem {
'Debian': {
if $::operatingsystemmajrelease <= 7 {
$initstyle = 'init'
} else {
$initstyle = 'systemd'
}
}
'Ubuntu': {
if $::lsbmajdistrelease <= 14 {
$initstyle = 'upstart'
} else {
$initstyle = 'systemd'
}
}
default: {
$conf_file = '/etc/rsync.conf'
$servicename = 'rsync'
$initstyle = 'init'
}
}
}
'RedHat': {
$conf_file = '/etc/rsyncd.conf'
$servicename = 'rsyncd'
if $::operatingsystemmajrelease <= 6 {
$initstyle = 'init'
} else {
$initstyle = 'systemd'
}
}
'suse': {
$conf_file = '/etc/rsyncd.conf'
$servicename = 'rsyncd'
if $::lsbdistrelease <= 11 {
$initstyle = 'init'
} else {
$initstyle = 'systemd'
}
}
'FreeBSD': {
$conf_file = '/usr/local/etc/rsync/rsyncd.conf'
$servicename = 'rsyncd'
$initstyle = 'bsd'
}
default: {
$conf_file = '/etc/rsync.conf'
$servicename = 'rsync'
$initstyle = 'init'
}
}
if $use_xinetd {
include xinetd
xinetd::service { 'rsync':
bind => $address,
port => '873',
nice => $nice,
server => '/usr/bin/ionice',
server_args => "-c${ionice} /usr/bin/rsync --daemon --config ${conf_file}",
require => Package['rsync'],
}
} else {
service { $servicename:
ensure => running,
enable => true,
hasstatus => true,
hasrestart => true,
subscribe => Concat[$conf_file],
}
if $initstyle == 'systemd' {
file { 'systemd_rsync_service_d':
ensure => directory,
path => "/etc/systemd/system/${servicename}.service.d",
}
file { 'systemd_nice':
path => "/etc/systemd/system/${servicename}.service.d/nice.conf",
content => "[Service]\nNice=${nice}",
require => File['systemd_rsync_service_d'],
notify => Service[$servicename],
}
file { 'systemd_ionice':
path => "/etc/systemd/system/${servicename}.service.d/ionice.conf",
content => "[Service]\nIOSchedulingClass=${ionice}",
require => File['systemd_rsync_service_d'],
notify => Service[$servicename],
}
}
if ( $::osfamily == 'Debian' ) {
file { '/etc/default/rsync':
content => template('rsync/defaults.erb'),
notify => Service['rsync'],
}
}
}
if $motd_file != 'UNSET' {
file { '/etc/rsync-motd':
source => 'puppet:///modules/rsync/motd',
}
}
concat { $conf_file: }
# Template uses:
# - $use_chroot
# - $address
# - $motd_file
concat::fragment { 'rsyncd_conf_header':
target => $conf_file,
content => template('rsync/header.erb'),
order => '00_header',
}
create_resources(rsync::server::module, $modules)
}