]> gitweb.fluxo.info Git - puppet-tftp.git/commitdiff
Add EL (RHEL/CentOS) support for tftp.
authorcrayfishx <craig@craigdunn.org>
Tue, 10 Jul 2012 19:51:23 +0000 (12:51 -0700)
committercrayfishx <craig@craigdunn.org>
Tue, 10 Jul 2012 19:51:23 +0000 (12:51 -0700)
 * EL tftpd-hpa package is called tftp-server
 * Distributed RPM doesn't provide an init file so the base provider is needed
 * Default username for tftp-server on RHEL is nobody
 * no /etc/default/tftpd-hpa should be pushed for EL systems

manifests/init.pp
manifests/params.pp

index 9dfab3793df5cebad1d8f3e8f62d73aabececc9c..5057eb278d7cf047522e3af755285b9a9331180e 100644 (file)
@@ -31,19 +31,26 @@ class tftp (
   $port       = $tftp::params::port,
   $options    = $tftp::params::options,
   $inetd      = false,
-  $inetd_conf = $tftp::params::inetd_conf
+  $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 {
@@ -77,12 +84,17 @@ class tftp (
     $svc_enable = true
   }
 
+  $start = $binary ? {
+    undef =>  undef,
+    default =>  "${binary} -l -a ${address}:${port} -u ${username} ${options} ${directory}"
+  }
+
   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,
   }
 }
index e6581840a7846fb3888b194a374afbfe2e725c7a..b688dd536585a94699a9c0675ba38f72dc9c4c75 100644 (file)
@@ -4,28 +4,52 @@
 class tftp::params {
   $address    = '0.0.0.0'
   $port       = '69'
-  $username   = 'tftp'
   $options    = '--secure'
   $inetd_conf = '/etc/inetd.conf'
 
-  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
+      $binary   = undef
+      $username = 'tftp'
+      case $::operatingsystem {
+        'debian': {
+          $directory  = '/srv/tftp'
+          $hasstatus  = false
+          $provider   = undef
+        }
+        'ubuntu': {
+          $directory  = '/var/lib/tftpboot'
+          $hasstatus  = true
+          $provider   = 'upstart'
+        }
+        default: {
+          $directory  = '/var/lib/tftpboot'
+          $hasstatus  = true
+          $provider   = undef
+          warning("tftp:: cannot determine settings for $::operatingsystem")
+        }
+      }
     }
-    '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'
+      $binary     = '/usr/sbin/in.tftpd'
     }
     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
+      $binary     = '/usr/sbin/in.tftpd'
+      warning("tftp:: $::operatingsystem may not be supported")
     }
   }
+
 }