]> gitweb.fluxo.info Git - puppet-tftp.git/commitdiff
Initial commit.
authorNan Liu <nan@puppetlabs.com>
Thu, 5 Apr 2012 20:42:52 +0000 (13:42 -0700)
committerNan Liu <nan@puppetlabs.com>
Thu, 5 Apr 2012 20:42:52 +0000 (13:42 -0700)
README.md [new file with mode: 0644]
manifests/file.pp [new file with mode: 0644]
manifests/init.pp [new file with mode: 0644]
manifests/params.pp [new file with mode: 0644]
templates/tftpd-hpa.erb [new file with mode: 0644]

diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..4bdd512
--- /dev/null
+++ b/README.md
@@ -0,0 +1,73 @@
+# puppet-tftp module
+
+## Overview
+
+Install tftp-hpa package and configuration files for osfamily Debian.
+
+## Usage
+
+### class tftp
+
+Parameters:
+
+* username: tftp daemon user, default tftp.
+* directory: service directory, deafult see params class.
+* address: bind address, default 0.0.0.0.
+* port: bind port, default 69.
+* options: service option, default --secure.
+
+    class tftp {
+      directory => '/opt/tftp',
+      address   => $::ipaddress,
+      options   => '--secure --ipv6 --timeout 60',
+    }
+
+### tftp::file
+
+Parameters:
+
+*  ensure: file type, default file.
+*  owner: file owner, default tftp.
+*  group: file group. default tftp.
+*  mode: file mode, default 0644 (puppet will change to 0755 for directories).
+*  content: file content.
+*  source: file source.
+
+    tftp::file { 'pxelinux.0':
+      source => 'puppet:///modules/acme/pxelinux.0',
+    }
+    
+    tftp::file { 'pxelinux.cfg':
+      ensure => directory,
+    }
+    
+    tftp::file { 'pxelinux.cfg/default':
+      source => 'puppet:///modules/acme/default',
+    }
+
+## Example
+
+1. tftp directories not in the OS package defaults should be managed as file resources.
+2. customization for the class tftp must be declared before using tftp::file resources.
+
+    file { '/opt/tftp':
+      ensure => directory,
+    }
+    
+    class { 'tftp':
+      directory => '/opt/tftp',
+      address   => $::ipaddress,
+    }
+    
+    tftp::file { 'pxelinux.0':
+      source => 'puppet:///modules/acme/pxelinux.0',
+    }
+
+The examples use a module acme and the tftp files should be placed in calling module path i.e. (/etc/puppet/modules/acme/files).
+
+## Supported Platforms
+
+The module have been tested on the following operating systems. Testing and patches for other platforms are welcomed.
+
+Debian Wheezy
+Ubuntu Oneiric
diff --git a/manifests/file.pp b/manifests/file.pp
new file mode 100644 (file)
index 0000000..72c9ebd
--- /dev/null
@@ -0,0 +1,30 @@
+# Define: tftp::file
+#
+# Parameters:
+#
+# Actions:
+#
+# Requires:
+#
+# Usage:
+#
+define tftp::file (
+  $ensure  = file,
+  $owner   = 'tftp',
+  $group   = 'tftp',
+  $mode    = '0644',
+  $content = undef,
+  $source  = undef
+) {
+  include 'tftp'
+
+  file { "${tftp::directory}/${name}":
+    ensure  => $ensure,
+    owner   => $owner,
+    group   => $group,
+    mode    => $mode,
+    content => $content,
+    source  => $source,
+    require => Class['tftp'],
+  }
+}
diff --git a/manifests/init.pp b/manifests/init.pp
new file mode 100644 (file)
index 0000000..0a38297
--- /dev/null
@@ -0,0 +1,38 @@
+# Class: tftp
+#
+# Parameters:
+#
+# Actions:
+#
+# Requires:
+#
+# Usage:
+#
+class tftp (
+  $username  = $tftp::params::username,
+  $directory = $tftp::params::directory,
+  $address   = $tftp::params::address,
+  $port      = $tftp::params::port,
+  $options   = $tftp::params::options
+) inherits tftp::params {
+  package { 'tftpd-hpa':
+    ensure => present,
+  }
+
+  file { '/etc/default/tftpd-hpa':
+    ensure  => file,
+    owner   => 'root',
+    group   => 'root',
+    mode    => '0644',
+    content => template('tftp/tftpd-hpa.erb'),
+    require => Package['tftpd-hpa'],
+  }
+
+  service { 'tftpd-hpa':
+    ensure    => running,
+    provider  => $tftp::params::provider,
+    hasstatus => $tftp::params::hasstatus,
+    pattern   => '/usr/sbin/in.tftpd',
+    subscribe => File['/etc/default/tftpd-hpa'],
+  }
+}
diff --git a/manifests/params.pp b/manifests/params.pp
new file mode 100644 (file)
index 0000000..df43e6c
--- /dev/null
@@ -0,0 +1,36 @@
+# Class: tftp::params
+#
+# Parameters:
+#
+# Actions:
+#
+# Requires:
+#
+# Usage:
+#
+class tftp::params {
+  $address  = '0.0.0.0'
+  $port     = '69'
+  $username = 'tftp'
+  $options  = '--secure'
+
+  case $::operatingsystem {
+    'debian': {
+      # hasstatus is to get around an issue where the service script appears to be broken.
+      $directory = '/srv/tftp'
+      $hasstatus = false
+      $provider  = undef
+    }
+    'ubuntu': {
+      $directory = '/var/lib/tftpboot'
+      $hasstatus = true
+      $provider  = 'upstart'
+    }
+    default: {
+      warning("tftp:: module not verified on operatingsystem ${::operatingsystem}.")
+      $directory = '/var/lib/tftpboot'
+      $hasstatus = true
+      $provider  = undef
+    }
+  }
+}
diff --git a/templates/tftpd-hpa.erb b/templates/tftpd-hpa.erb
new file mode 100644 (file)
index 0000000..89f7e1f
--- /dev/null
@@ -0,0 +1,6 @@
+# /etc/default/tftpd-hpa
+
+TFTP_USERNAME="<%= username %>"
+TFTP_DIRECTORY="<%= directory %>"
+TFTP_ADDRESS="<%= address %>:<%= port %>"
+TFTP_OPTIONS="<%= options %>"