Defined Type: consul::check

Defined in:
manifests/check.pp

Summary

Sets up a Consul healthcheck

Overview

Parameters:

  • ensure (Any) (defaults to: present)

    Define availability of check. Use ‘absent’ to remove existing checks

  • http (Any) (defaults to: undef)

    HTTP endpoint for the service healthcheck

  • id (Any) (defaults to: $title)

    The id for the check (defaults to $title)

  • interval (Any) (defaults to: undef)

    Value in seconds for the interval between runs of the check

  • notes (Any) (defaults to: undef)

    Human readable description of the check

  • script (Any) (defaults to: undef)

    Full path to the location of the healthcheck script. Must be nagios compliant with regards to the return codes. This parameter is deprecated in Consul 1.0.0, see github.com/hashicorp/consul/issues/3509.

  • args (Any) (defaults to: undef)

    Arguments to be ‘exec`ed for the healthcheck script.

  • service_id (Any) (defaults to: undef)

    An optional service_id to match this check against

  • status (Any) (defaults to: undef)

    The default state of the check when it is registered against a consul agent. Should be either “critical” or “passing”

  • tcp (Any) (defaults to: undef)

    The IP/hostname and port for the service healthcheck. Should be in ‘hostname:port’ format.

  • grpc (Any) (defaults to: undef)

    GRPC endpoint for the service healthcheck

  • timeout (Any) (defaults to: undef)

    A timeout value for HTTP request only

  • token (Any) (defaults to: undef)

    ACL token for interacting with the catalog (must be ‘management’ type)

  • ttl (Any) (defaults to: undef)

    Value in seconds before the http endpoint considers a failing healthcheck to be “HARD” down.

  • success_before_passing (Any) (defaults to: undef)

    Value may be set to become check passing only after a specified number of consecutive checks return passing

  • failures_before_critical (Any) (defaults to: undef)

    Value may be set to become check critical only after a specified number of consecutive checks return critical

See Also:



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

define consul::check (
  $ensure                   = present,
  $http                     = undef,
  $id                       = $title,
  $interval                 = undef,
  $notes                    = undef,
  $script                   = undef,
  $args                     = undef,
  $service_id               = undef,
  $status                   = undef,
  $tcp                      = undef,
  $grpc                     = undef,
  $timeout                  = undef,
  $token                    = undef,
  $ttl                      = undef,
  $success_before_passing   = undef,
  $failures_before_critical = undef,
) {
  include consul

  $basic_hash = {
    'id'                       => $id,
    'name'                     => $name,
    'ttl'                      => $ttl,
    'http'                     => $http,
    'script'                   => $script,
    'args'                     => $args,
    'tcp'                      => $tcp,
    'grpc'                     => $grpc,
    'interval'                 => $interval,
    'timeout'                  => $timeout,
    'service_id'               => $service_id,
    'notes'                    => $notes,
    'token'                    => $token,
    'status'                   => $status,
    'success_before_passing'   => $success_before_passing,
    'failures_before_critical' => $failures_before_critical,
  }

  $check_hash = {
    check => $basic_hash.filter |$key, $val| { $val =~ NotUndef },
  }

  consul::validate_checks($check_hash[check])

  $escaped_id = regsubst($id,'\/','_','G')
  file { "${consul::config_dir}/check_${escaped_id}.json":
    ensure  => $ensure,
    owner   => $consul::user_real,
    group   => $consul::group_real,
    mode    => $consul::config_mode,
    content => consul::sorted_json($check_hash, $consul::pretty_config, $consul::pretty_config_indent),
    notify  => Class['consul::reload_service'],
  }
}