Defined Type: lmhosts::host

Defined in:
manifests/host.pp

Summary

Add a host entry to the lmhosts file.

Overview

A host entry consists of an IPv4 address, an smb netbios name, and some optional flags.

Examples:

lmhosts::host { '/etc/lmhosts localhost':
  address: '127.0.0.1',
  preload: true,
}

Parameters:

  • address (Stdlib::IP::Address::V4::Nosubnet)

    The IPv4 address of this host entry.

  • ensure (Enum['absent','present']) (defaults to: 'present')

    Whether to remove (‘absent’) or add (‘present’) this host entry.

  • domain (Optional[Lmhosts::Host::Name]) (defaults to: undef)

    The Samba domain to which this host will be added, if diferent from the default domain.

  • host (Lmhosts::Host::Name) (defaults to: regsubst($title, /\A(.+)[ ]([^\\\/:*?"<>|]{1,15})\z/, '\\2'))

    The netbios name of this computer or service.

  • index (Optional[Lmhosts::Order]) (defaults to: undef)

    Used by the concat module to assemble the lmhosts file from parts.

  • multiple (Boolean) (defaults to: false)

    If true, this is one of up to 25 entries for the same host.

  • path (Stdlib::Absolutepath) (defaults to: regsubst($title, /\A(.+)[ ]([^\\\/:*?"<>|]{1,15})\z/, '\\1'))

    The location of the lmhosts file.

  • preload (Boolean) (defaults to: true)

    If true (default), this entry should be preloaded into cache.

  • service (Optional[Integer[0x00,0xff]]) (defaults to: undef)

    An optional integer service code. See $lmhosts::host::service



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'manifests/host.pp', line 40

define lmhosts::host (
  Stdlib::IP::Address::V4::Nosubnet $address,
  Enum['absent','present']          $ensure   = 'present',
  Optional[Lmhosts::Host::Name]     $domain   = undef,
  Lmhosts::Host::Name               $host     = regsubst($title, /\A(.+)[ ]([^\\\/:*?"<>|]{1,15})\z/, '\\2'),
  Optional[Lmhosts::Order]          $index    = undef,
  Boolean                           $multiple = false,
  Stdlib::Absolutepath              $path     = regsubst($title, /\A(.+)[ ]([^\\\/:*?"<>|]{1,15})\z/, '\\1'),
  Boolean                           $preload  = true,
  Optional[Integer[0x00,0xff]]      $service  = undef,
) {
  $_address = sprintf('%-15s', $address)
  $_domain = $domain ? {
    undef   => '',
    default => " #DOM:${domain}"
  }
  $_host = $service ? {
    undef   => sprintf('%-22s', $host),
    default => sprintf('"%-15s\\0x%2x"', $host, $service),
  }
  $_multiple = $multiple? {
    false   => '',
    default => ' #MH',
  }
  $_preload = $preload ? {
    false   => '',
    default => ' #PRE',
  }
  $_content = strip("${_address} ${_host}${_multiple}${_preload}")
  concat::fragment { "lmhosts::host ${title}":
    content => "${_content}\r\n",
    order   => $index,
    target  => $path,
  }
}