diff options
| author | Nan Liu <nan.liu@gmail.com> | 2012-05-17 09:11:53 -0700 | 
|---|---|---|
| committer | Nan Liu <nan.liu@gmail.com> | 2012-05-17 09:11:53 -0700 | 
| commit | 25652f4645e09a89a3e5d749958f89d00050175d (patch) | |
| tree | 9118eb6838bfdd39ba20230b8e5c01be98fe8960 /manifests | |
| parent | edd39b0301a7db0af5098baf7a0b228036038493 (diff) | |
| parent | 9038a12755c60ce3a7da3cac7274cadcf82057dc (diff) | |
| download | puppet-tftp-25652f4645e09a89a3e5d749958f89d00050175d.tar.gz puppet-tftp-25652f4645e09a89a3e5d749958f89d00050175d.tar.bz2 | |
Merge pull request #4 from branan/tb/14465
(#14465) Add inetd option for tftpd.
Diffstat (limited to 'manifests')
| -rw-r--r-- | manifests/init.pp | 62 | ||||
| -rw-r--r-- | manifests/params.pp | 9 | 
2 files changed, 61 insertions, 10 deletions
| diff --git a/manifests/init.pp b/manifests/init.pp index 0a38297..13954b5 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -2,18 +2,36 @@  #  # 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*]: tftp service bind port (default 69). +#   [*inetd_conf*]: tftp service bind port (default 69). +#  # Actions:  #  # Requires:  # +#   puppetlabs-inetd when inetd = 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 +  $username   = $tftp::params::username, +  $directory  = $tftp::params::directory, +  $address    = $tftp::params::address, +  $port       = $tftp::params::port, +  $options    = $tftp::params::options, +  $inetd      = false, +  $inetd_conf = $tftp::params::inetd_conf  ) inherits tftp::params {    package { 'tftpd-hpa':      ensure => present, @@ -28,8 +46,40 @@ class tftp (      require => Package['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'], +    } + +    $svc_ensure = stopped +    $svc_enable = false +  } else { +    $svc_ensure = running +    $svc_enable = true +  } +    service { 'tftpd-hpa': -    ensure    => running, +    ensure    => $svc_ensure, +    enable    => $svc_enable,      provider  => $tftp::params::provider,      hasstatus => $tftp::params::hasstatus,      pattern   => '/usr/sbin/in.tftpd', diff --git a/manifests/params.pp b/manifests/params.pp index b268114..564e0f2 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -9,10 +9,11 @@  # Usage:  #  class tftp::params { -  $address  = '0.0.0.0' -  $port     = '69' -  $username = 'tftp' -  $options  = '--secure' +  $address    = '0.0.0.0' +  $port       = '69' +  $username   = 'tftp' +  $options    = '--secure' +  $inetd_conf = '/etc/inetd.conf'    case $::operatingsystem {      'debian': { | 
