Puppet Class: r_profile::web_service::tomcat

Defined in:
manifests/web_service/tomcat.pp

Overview

R_profile::Web_service::Tomcat

Install and configure tomcat application server

Parameters:

  • source_url (Any) (defaults to: 'http://apache.mirror.amaze.com.au/tomcat/tomcat-8/v8.5.14/bin/apache-tomcat-8.5.14.tar.gz')
  • catalina_home (Any) (defaults to: '/opt/tomcat')
  • service (Any) (defaults to: 'tomcat')
  • user (Any) (defaults to: 'tomcat')
  • group (Any) (defaults to: 'tomcat')
  • port (Any) (defaults to: 8080)
  • lb (Any) (defaults to: true)
  • nagios_monitored (Any) (defaults to: true)
  • open_firewall (Any) (defaults to: false)


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
81
82
83
84
85
86
# File 'manifests/web_service/tomcat.pp', line 4

class r_profile::web_service::tomcat(
    $source_url       = 'http://apache.mirror.amaze.com.au/tomcat/tomcat-8/v8.5.14/bin/apache-tomcat-8.5.14.tar.gz',
    $catalina_home    = '/opt/tomcat',
    $service          = 'tomcat',
    $user             = 'tomcat',
    $group            = 'tomcat',
    $port             = 8080,
    $lb               = true,
    $nagios_monitored = true,
    $open_firewall    = false,
){

  # for processing .war files
  ensure_packages('unzip', {'ensure' => 'present'})

  include r_profile::java

  class { 'tomcat':
    catalina_home => $catalina_home,
    user          => $user,
    group         => $group,
  }

  tomcat::install { $catalina_home:
    source_url => $source_url,
  }

  tomcat::service { $service:
    require => Tomcat::Install[$catalina_home]
  }

  if $lb {

    # setup the FACT that will tell us what IP address to use (run n)
    if is_string($lb) {
      $lb_address = $lb
    } else {
      # attempt to lookup which nodes are classified as Haproxies and use first
      # check storedconfigs to ensure we are not running under rspec/puppet apply
      $lb_addresses = $::settings::storeconfigs ? {
        true    => query_nodes('Class[R_profile::Monitor::Haproxy]'),
        default => false,
      }
      if is_array($lb_addresses) {
        $lb_address = $lb_addresses[0]
      } else {
        $lb_address = false
      }
    }

    if $lb_address and is_string($lb) {
      $source_ip = $source_ipaddress[$lb_address]
    } else {
      $source_ip = undef
    }

    # export the IP address (run n+1)
    @@haproxy::balancermember { "${service}-${::fqdn}":
      listening_service => 'tomcat',
      server_names      => $::fqdn,
      ipaddresses       => $source_ip,
      ports             => $port,
      options           => 'check',
    }

    # runs will be collected on the loadbalancer next time it runs puppet
  }

  if $nagios_monitored {
    nagios::nagios_service_http { 'tomcat':
      port => $port,
      url  => '/',
    }
  }

  if $open_firewall and !defined(Firewall["100 ${::fqdn} HTTP ${port}"]) {
    firewall { "100 ${::fqdn} HTTP ${port}":
      dport  => $port,
      proto  => 'tcp',
      action => 'accept',
    }
  }
}