5
6
7
8
9
10
11
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
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
99
100
101
102
|
# File 'manifests/docker/kibana.pp', line 5
define cfwebapp::docker::kibana (
Array[String[1]] $ifaces = ['local'],
CfWeb::DBAccess $app_dbaccess = { cluster => 'logsink' },
String[1] $server_name = $title,
Hash[String[1],Any] $auto_cert = {},
CfWeb::SharedCert $shared_cert = [],
Boolean $is_backend = false,
Boolean $robots_noindex = true,
Integer[1] $memory_weight = 100,
Integer[128] $memory_min = 512,
Optional[Integer[128]] $memory_max = 512,
Hash[String[1], Any] $kibana_tune = {},
Hash[String[1], Any] $site_params = {},
CfWeb::DockerImage $image = {
image => 'docker.elastic.co/kibana/kibana-oss',
image_tag => '6.7.1',
},
Cfnetwork::Port $target_port = 5601,
) {
include cfweb::nginx
$user = "app_${title}"
$site_dir = "${cfweb::nginx::web_dir}/${user}"
$kibana_tune_all = {
'elasticsearch.pingTimeout' => 3000,
'elasticsearch.preserveHost' => false,
'elasticsearch.requestHeadersWhitelist' => [],
'elasticsearch.requestTimeout' => 30000,
'kibana.defaultAppId' => 'discover',
} + $kibana_tune + {
'server.name' => $server_name,
'server.host' => '0.0.0.0',
'server.port' => $target_port,
'logging.json' => false,
}
# ---
ensure_resource('package', 'kibana', { ensure => absent })
# ---
$config_file = "${site_dir}/persistent/kibana.yml"
ensure_resource('cfweb::site', $title, $site_params + {
server_name => $server_name,
ifaces => $ifaces,
auto_cert => $auto_cert,
shared_cert => $shared_cert,
is_backend => $is_backend,
robots_noindex => $robots_noindex,
dbaccess => {
app => $app_dbaccess + {
config_prefix => 'DB_',
use_unix_socket => false,
local_iface => 'docker',
},
},
apps => {
docker => {
memory_weight => $memory_weight,
memory_min => $memory_min,
memory_max => $memory_max,
},
},
deploy => {
target_port => $target_port,
image => $image,
binds => {
'kibana.yml' => '/usr/share/kibana/config/kibana.yml',
},
custom_script => @("EOT"/$)
#!/bin/bash
set -e
source .env
CONF_FILE=${config_file}
# DB
#----
cat >\$CONF_FILE.tmp <<EOF
${to_yaml($kibana_tune_all)}
elasticsearch.hosts: http://\${DB_HOST}:\${DB_PORT}
EOF
mv -f \$CONF_FILE.tmp \$CONF_FILE
chmod 644 \$CONF_FILE
| EOT
,
config_files => [$config_file],
},
})
}
|