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
|
# Class: tftp
#
# Parameters:
#
# [*username*]: tftp service username.
# [*directory*]: tftp service file directory.
# [*address*]: tftp service bind address (default 0.0.0.0).
# [*port*]: tftp service bind port (default 69).
# [*options*]: tftp service bind port (default 69).
# [*inetd*]: Run as an xinetd service instead of standalone daemon (false)
#
# Actions:
#
# Requires:
#
# Class['xinetd'] (if inetd set to true)
#
# Usage:
#
# class { 'tftp':
# directory => '/opt/tftp',
# address => $::ipaddress,
# options => '--ipv6 --timeout 60',
# }
#
class tftp (
$username = $tftp::params::username,
$directory = $tftp::params::directory,
$address = $tftp::params::address,
$port = $tftp::params::port,
$options = $tftp::params::options,
$inetd = $tftp::params::inetd,
$package = $tftp::params::package,
$binary = $tftp::params::binary,
$defaults = $tftp::params::defaults
) inherits tftp::params {
package { 'tftpd-hpa':
ensure => present,
name => $package,
}
if $defaults {
file { '/etc/default/tftpd-hpa':
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
content => template('tftp/tftpd-hpa.erb'),
require => Package['tftpd-hpa'],
notify => Service['tftpd-hpa'],
}
}
if $inetd {
include 'xinetd'
xinetd::service { 'tftp':
port => $port,
protocol => 'udp',
server_args => "${options} -u ${username} ${directory}",
server => $binary,
user => 'root',
group => 'root',
bind => $address,
socket_type => 'dgram',
cps => '100 2',
flags => 'IPv4',
per_source => '11',
wait => 'yes',
}
$svc_ensure = stopped
$svc_enable = false
} else {
$svc_ensure = running
$svc_enable = true
}
$start = $provider ? {
'base' => "${binary} -l -a ${address}:${port} -u ${username} ${options} ${directory}",
default => undef
}
service { 'tftpd-hpa':
ensure => $svc_ensure,
enable => $svc_enable,
provider => $tftp::params::provider,
hasstatus => $tftp::params::hasstatus,
pattern => '/usr/sbin/in.tftpd',
start => $start,
}
}
|