Puppet Class: tomcat::log4j

Defined in:
manifests/log4j.pp

Overview

Class: tomcat::log4j



3
4
5
6
7
8
9
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
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
75
76
77
78
79
80
# File 'manifests/log4j.pp', line 3

class tomcat::log4j {
  # The base class must be included first
  if !defined(Class['tomcat']) {
    fail('You must include the tomcat base class before using any tomcat sub class')
  }

  # warn user if log4j is not installed
  unless $::tomcat::log4j {
    warning('Logging with log4j will not work unless the log4j library is installed')
  }

  # generate OS-specific variables
  $log4j_path = $::osfamily ? {
    'Debian' => '/usr/share/java/log4j-1.2.jar',
    default  => '/usr/share/java/log4j.jar'
  }

  $notify_service = $::tomcat::restart_on_change ? {
    true  => Service[$::tomcat::service_name_real],
    false => undef,
  }

  file { 'global log4j library':
    ensure => link,
    owner  => 'root',
    group  => 'root',
    path   => "${::tomcat::catalina_home_real}/lib/log4j.jar",
    target => $log4j_path,
    notify => $notify_service
  }

  if $::tomcat::log4j_conf_type == 'xml' {
    file {
      'global log4j xml configuration':
        ensure => present,
        owner  => 'root',
        group  => 'root',
        path   => "${::tomcat::catalina_home_real}/lib/log4j.xml",
        source => $::tomcat::log4j_conf_source,
        notify => $notify_service;

      'global log4j ini configuration':
        ensure => absent,
        path   => "${::tomcat::catalina_home_real}/lib/log4j.properties";

      'global log4j dtd file':
        ensure => present,
        owner  => 'root',
        group  => 'root',
        path   => "${::tomcat::catalina_home_real}/lib/log4j.dtd",
        source => "puppet:///modules/${module_name}/log4j/log4j.dtd"
    }
  } else {
    file {
      'global log4j ini configuration':
        ensure => present,
        owner  => 'root',
        group  => 'root',
        path   => "${::tomcat::catalina_home_real}/lib/log4j.properties",
        source => $::tomcat::log4j_conf_source,
        notify => $notify_service;

      'global log4j xml configuration':
        ensure => absent,
        path   => "${::tomcat::catalina_home_real}/lib/log4j.xml";

      'global log4j dtd file':
        ensure => absent,
        path   => "${::tomcat::catalina_home_real}/lib/log4j.dtd"
    }
  }

  file { 'global logging configuration':
    ensure => absent,
    path   => "${::tomcat::catalina_base_real}/conf/logging.properties",
    backup => true
  }
}