Puppet Class: prometheusforemansd::service

Defined in:
manifests/service.pp

Overview

Class prometheusforemansd::service

This class is meant to be called from prometheusforemansd It ensure the service is running



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'manifests/service.pp', line 6

class prometheusforemansd::service {
  case $::prometheusforemansd::install_method {
    'archive': {
      $service_path   = "${::prometheusforemansd::install_dir}/prometheus-foreman-sd"
      $service_config = "${::prometheusforemansd::install_dir}/prometheusforemansd.yaml"

      if !defined(Service[$::prometheusforemansd::service_name]){
        service { $::prometheusforemansd::service_name:
          ensure     => running,
          provider   => base,
          binary     => "su - root -c '${service_path} server --config=${service_config} &'",
          stop       => "ps -ef | grep prometheus-foreman-sd | grep -v grep | awk '{print \$2}' | xargs -r kill -9",
          hasrestart => false,
          hasstatus  => false,
          status     => "ps -ef | grep prometheus-foreman-sd | grep -v grep"
        }
      }
    }
    default: {
      fail("Installation method ${::prometheusforemansd::install_method} not supported")
    }
  }
}