Defined Type: tomcat::war

Defined in:
manifests/war.pp

Summary

Manage deployment of WAR files.

Overview

Parameters:

  • catalina_base (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Specifies the base directory of the Tomcat installation. Valid options: a string containing an absolute path. ‘$::tomcat::catalina_home`.

  • app_base (Optional[String[1]]) (defaults to: undef)

    Specifies where to deploy the WAR. Cannot be used in combination with ‘deployment_path`. Valid options: a string containing a path relative to `$CATALINA_BASE`. `app_base`, Puppet deploys the WAR to your specified `deployment_path`. If you don’t specify that either, the WAR deploys to ‘$catalina_base/webapps`.

  • deployment_path (Optional[String[1]]) (defaults to: undef)

    Specifies where to deploy the WAR. Cannot be used in combination with ‘app_base`. Valid options: a string containing an absolute path. `deployment_path`, Puppet deploys the WAR to your specified `app_base`. If you don’t specify that either, the WAR deploys to ‘$catalina_base/webapps`.

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

    Specifies whether the WAR should exist.

  • war_name (Optional[String[1]]) (defaults to: undef)

    Specifies the name of the WAR. Valid options: a string containing a filename that ends in ‘.war’. ‘name` passed in your defined type.

  • war_purge (Boolean) (defaults to: true)

    Specifies whether to purge the exploded WAR directory. Only applicable when ‘war_ensure` is set to ’absent’ or ‘false`.

  • war_source (Optional[String[1]]) (defaults to: undef)

    Specifies the source to deploy the WAR from. Valid options: a string containing a ‘puppet://`, `http(s)://`, or `ftp://` URL.

  • allow_insecure (Boolean) (defaults to: false)

    Specifies if HTTPS errors should be ignored when downloading the war tarball.

  • user (String[1]) (defaults to: 'tomcat')

    The ‘owner’ of the tomcat war file.

  • group (String[1]) (defaults to: 'tomcat')

    The ‘group’ owner of the tomcat war file.



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
87
88
89
90
91
92
93
94
95
96
97
98
# File 'manifests/war.pp', line 24

define tomcat::war (
  Optional[Stdlib::Absolutepath] $catalina_base   = undef,
  Optional[String[1]]            $app_base        = undef,
  Optional[String[1]]            $deployment_path = undef,
  Enum['present','absent']       $war_ensure      = 'present',
  Optional[String[1]]            $war_name        = undef,
  Boolean                        $war_purge       = true,
  Optional[String[1]]            $war_source      = undef,
  Boolean                        $allow_insecure  = false,
  String[1]                      $user            = 'tomcat',
  String[1]                      $group           = 'tomcat',
) {
  include tomcat
  $_catalina_base = pick($catalina_base, $tomcat::catalina_home)
  tag(sha1($_catalina_base))

  if $app_base and $deployment_path {
    fail('Only one of $app_base and $deployment_path can be specified.')
  }

  if $war_name {
    $_war_name = $war_name
  } else {
    $_war_name = $name
  }

  if $_war_name !~ /\.war$/ {
    fail('war_name must end with .war')
  }

  if $deployment_path {
    $_deployment_path = $deployment_path
  } else {
    if $app_base {
      $_app_base = $app_base
    } else {
      $_app_base = 'webapps'
    }
    $_deployment_path = "${_catalina_base}/${_app_base}"
  }

  if $war_ensure == 'absent' {
    file { "${_deployment_path}/${_war_name}":
      ensure => absent,
      force  => false,
    }
    if $war_purge {
      $war_dir_name = regsubst($_war_name, '\.war$', '')
      if $war_dir_name != '' {
        file { "${_deployment_path}/${war_dir_name}":
          ensure => absent,
          force  => true,
        }
      }
    }
  } else {
    if ! $war_source {
      fail('$war_source must be specified if you aren\'t removing the WAR')
    }
    archive { "tomcat::war ${name}":
      extract        => false,
      source         => $war_source,
      path           => "${_deployment_path}/${_war_name}",
      allow_insecure => $allow_insecure,
    }
    file { "tomcat::war ${name}":
      ensure    => file,
      path      => "${_deployment_path}/${_war_name}",
      owner     => $user,
      group     => $group,
      mode      => '0640',
      subscribe => Archive["tomcat::war ${name}"],
    }
  }
}