aboutsummaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
Diffstat (limited to 'manifests')
-rw-r--r--manifests/init.pp73
-rw-r--r--manifests/params.pp47
2 files changed, 69 insertions, 51 deletions
diff --git a/manifests/init.pp b/manifests/init.pp
index 9dfab37..973049c 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -7,14 +7,13 @@
# [*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*]: tftp service bind port (default 69).
-# [*inetd_conf*]: tftp service bind port (default 69).
+# [*inetd*]: Run as an xinetd service instead of standalone daemon (false)
#
# Actions:
#
# Requires:
#
-# puppetlabs-inetd when inetd = true.
+# Class['xinetd'] (if inetd set to true)
#
# Usage:
#
@@ -31,45 +30,44 @@ class tftp (
$port = $tftp::params::port,
$options = $tftp::params::options,
$inetd = false,
- $inetd_conf = $tftp::params::inetd_conf
+ $package = $tftp::params::package,
+ $binary = $tftp::params::binary,
+ $defaults = $tftp::params::defaults
) inherits tftp::params {
+
package { 'tftpd-hpa':
- ensure => present,
+ ensure => present,
+ name => $package,
}
-
- file { '/etc/default/tftpd-hpa':
- ensure => file,
- owner => 'root',
- group => 'root',
- mode => '0644',
- content => template('tftp/tftpd-hpa.erb'),
- require => Package['tftpd-hpa'],
+ 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 {
- if $options != '--secure' {
- fail('tftp class does not support custom options when inetd is enabled.')
- }
-
- include 'inetd'
- augeas { 'inetd_tftp':
- changes => [
- "ins tftp after /files${inetd_conf}",
- "set /files${inetd_conf}/tftp/socket dgram",
- "set /files${inetd_conf}/tftp/protocol udp",
- "set /files${inetd_conf}/tftp/wait wait",
- "set /files${inetd_conf}/tftp/user ${username}",
- "set /files${inetd_conf}/tftp/command /usr/libexec/tftpd",
- "set /files${inetd_conf}/tftp/arguments/1 tftpd",
- "set /files${inetd_conf}/tftp/arguments/2 --address",
- "set /files${inetd_conf}/tftp/arguments/3 ${address}:${port}",
- "set /files${inetd_conf}/tftp/arguments/4 --secure",
- "set /files${inetd_conf}/tftp/arguments/5 ${directory}",
- ],
- require => Class['inetd'],
- }
+ include 'xinetd'
+ xinetd::service { 'tftp':
+ port => $port,
+ protocol => 'udp',
+ server_args => "${options} ${directory}",
+ server => $binary,
+ user => $username,
+ bind => $address,
+ socket_type => 'dgram',
+ cps => '100 2',
+ flags => 'IPv4',
+ per_source => '11',
+ wait => 'yes',
+ }
$svc_ensure = stopped
$svc_enable = false
} else {
@@ -77,12 +75,17 @@ class tftp (
$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',
- subscribe => File['/etc/default/tftpd-hpa'],
+ start => $start,
}
}
diff --git a/manifests/params.pp b/manifests/params.pp
index e658184..3520068 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -4,28 +4,43 @@
class tftp::params {
$address = '0.0.0.0'
$port = '69'
- $username = 'tftp'
$options = '--secure'
- $inetd_conf = '/etc/inetd.conf'
+ $binary = '/usr/sbin/in.tftpd'
- case $::operatingsystem {
+ case $::osfamily {
'debian': {
- # hasstatus is to get around an issue where the service script appears to
- # be broken.
- $directory = '/srv/tftp'
- $hasstatus = false
- $provider = undef
+ $package = 'tftpd-hpa'
+ $defaults = true
+ $username = 'tftp'
+ case $::operatingsystem {
+ 'debian': {
+ $directory = '/srv/tftp'
+ $hasstatus = false
+ $provider = undef
+ }
+ 'ubuntu': {
+ $directory = '/var/lib/tftpboot'
+ $hasstatus = true
+ $provider = 'upstart'
+ }
+ }
}
- 'ubuntu': {
- $directory = '/var/lib/tftpboot'
- $hasstatus = true
- $provider = 'upstart'
+ 'redhat': {
+ $package = 'tftp-server'
+ $username = 'nobody'
+ $defaults = false
+ $directory = '/var/lib/tftpboot'
+ $hasstatus = false
+ $provider = 'base'
}
default: {
- warning("tftp:: not verified on operatingsystem ${::operatingsystem}.")
- $directory = '/var/lib/tftpboot'
- $hasstatus = true
- $provider = undef
+ $package = 'tftpd'
+ $username = 'nobody'
+ $defaults = false
+ $hasstatus = false
+ $provider = undef
+ warning("tftp:: $::operatingsystem may not be supported")
}
}
+
}