Defined Type: tomcat::config::server::service

Defined in:
manifests/config/server/service.pp

Summary

Configure a Service element nested in the Server element in $CATALINA_BASE/conf/server.xml

Overview

Parameters:

  • catalina_base (Any) (defaults to: undef)

    Specifies the base directory of the Tomcat installation. Valid options: a string containing an absolute path.

  • class_name (Any) (defaults to: undef)

    Specifies the Java class name of a server implementation to use. Maps to the [className XML attribute](tomcat.apache.org/tomcat-8.0-doc/config/service.html#Common_Attributes). Valid options: a string containing a Java class name.

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

    Specifies whether the [className XML attribute](tomcat.apache.org/tomcat-8.0-doc/config/service.html#Common_Attributes) should exist in the configuration file.

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

    Specifies whether the [Service element](tomcat.apache.org/tomcat-8.0-doc/config/service.html#Introduction) should exist in the configuration file.

  • server_config (Any) (defaults to: undef)

    Specifies a server.xml file to manage. Valid options: a string containing an absolute path.

  • show_diff (Boolean) (defaults to: true)

    Specifies display differences when augeas changes files, defaulting to true. Valid options: true or false.



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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'manifests/config/server/service.pp', line 16

define tomcat::config::server::service (
  $catalina_base                              = undef,
  $class_name                                 = undef,
  Enum['present','absent'] $class_name_ensure = 'present',
  Enum['present','absent'] $service_ensure    = 'present',
  $server_config                              = undef,
  Boolean $show_diff                          = true,
) {
  include ::tomcat
  $_catalina_base = pick($catalina_base, $::tomcat::catalina_home)
  tag(sha1($_catalina_base))

  if versioncmp($::augeasversion, '1.0.0') < 0 {
    fail('Server configurations require Augeas >= 1.0.0')
  }

  if $server_config {
    $_server_config = $server_config
  } else {
    $_server_config = "${_catalina_base}/conf/server.xml"
  }

  if $service_ensure == 'absent' {
    $changes = "rm Server/Service[#attribute/name='${name}']"
  } else {
    if $class_name_ensure == 'absent' {
      $_class_name = "rm Server/Service[#attribute/name='${name}']/#attribute/className"
    } elsif $class_name {
      $_class_name = "set Server/Service[#attribute/name='${name}']/#attribute/className ${class_name}"
    } else {
      $_class_name = undef
    }
    $_service = "set Server/Service[#attribute/name='${name}']/#attribute/name ${name}"
    $changes = delete_undef_values([$_service, $_class_name])
  }

  if ! empty($changes) {
    augeas { "server-${_catalina_base}-service-${name}":
      lens      => 'Xml.lns',
      incl      => $_server_config,
      changes   => $changes,
      show_diff => $show_diff,
    }
  }
}