Defined Type: chsubserver

Defined in:
manifests/init.pp

Overview

Chrctcp

Manage services in /etc/inetd with chsubserver

Parameters:

  • proto

    key - inetd service to manage in the form service->protocol, eg echo->udp

  • ensuretodisableaserviceortoenableit ('disabled''enabled')

    nsure ‘disabled’ to disable a service or ‘enabled’ to enable it

  • refresh_service (Boolean) (defaults to: true)

    True to HUP the service after disabling otherwise false

  • params (String) (defaults to: '')

    Optional parameters to add to the inetd line, eg “ftpd -l -u077”

  • key (String) (defaults to: $title)
  • ensure (Enum['disabled', 'enabled']) (defaults to: 'disabled')


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
# File 'manifests/init.pp', line 10

define chsubserver(
    String                      $key              = $title,
    Enum['disabled', 'enabled'] $ensure           = 'disabled',
    Boolean                     $refresh_service  = true,
    String                      $params           = '',
) {
  $file = "/etc/inetd.conf"

  if $key.match(/.+->.+/) {
    $key_split  = split($key, '->')
    $service    = $key_split[0]
    $proto      = $key_split[1]

    if $ensure == "disabled" {
      $_ensure  = "-d"
      $op_match = ""
    } else {
      $_ensure  = "-a"
      $op_match = "#"
    }

    if $refresh_service {
      $_refresh_service = "-r inetd"
    } else {
      $_refresh_service = ""
    }

    exec { "chrctcp ${title}":
      command => "chsubserver ${refresh_service} -C ${file} ${_ensure} -v ${service} -p ${proto} ${params}",
      onlyif  => "grep '^${op_match}.*${service}.*${params}' < ${file}",
      path    => ["/usr/bin", "/usr/sbin"]
    }
  } else {
    fail("Incorrect key format for :'${key}, needs to be service->protcol, eg echo->udp")
  }
}