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 (
Enum['absent', 'present'] $ensure = present,
Optional $http = undef,
String[1] $id = $title,
Optional $interval = undef,
Optional $notes = undef,
Optional $script = undef,
Optional $args = undef,
Optional $service_id = undef,
Optional $status = undef,
Optional $tcp = undef,
Optional $grpc = undef,
Optional $timeout = undef,
Optional $token = undef,
Optional $ttl = undef,
Optional $success_before_passing = undef,
Optional $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'],
}
}
|