Puppet Class: elasticsearch::service

Defined in:
manifests/service.pp

Overview

This class exists to coordinate all service management related actions, functionality and logical units in a central place.

Note: “service” is the Puppet term and type for background processes in general and is used in a platform-independent way. E.g. “service” means “daemon” in relation to Unix-like systems.

Author:

  • Richard Pijnenburg <richard.pijnenburg@elasticsearch.com>

  • Tyler Langlois <tyler.langlois@elastic.co>

  • Gavin Williams <gavin.williams@elastic.co>



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
# File 'manifests/service.pp', line 12

class elasticsearch::service {
  #### Service management

  if $elasticsearch::ensure == 'present' {
    case $elasticsearch::status {
      # make sure service is currently running, start it on boot
      'enabled': {
        $_service_ensure = 'running'
        $_service_enable = true
      }
      # make sure service is currently stopped, do not start it on boot
      'disabled': {
        $_service_ensure = 'stopped'
        $_service_enable = false
      }
      # make sure service is currently running, do not start it on boot
      'running': {
        $_service_ensure = 'running'
        $_service_enable = false
      }
      # do not start service on boot, do not care whether currently running
      # or not
      'unmanaged': {
        $_service_ensure = undef
        $_service_enable = false
      }
      default: {
      }
    }
  } else {
    # make sure the service is stopped and disabled (the removal itself will be
    # done by package.pp)
    $_service_ensure = 'stopped'
    $_service_enable = false
  }

  service { $elasticsearch::service_name:
    ensure => $_service_ensure,
    enable => $_service_enable,
  }
}