instance.cfg.in 8.8 KB
Newer Older
Jérome Perrin's avatar
Jérome Perrin committed
1 2 3 4 5 6 7 8 9 10
[buildout]
parts =
  promises
  publish-connection-parameter

eggs-directory = {{ buildout['eggs-directory'] }}
develop-eggs-directory = {{ buildout['develop-eggs-directory'] }}
offline = true


11

Jérome Perrin's avatar
Jérome Perrin committed
12 13
[instance-parameter]
recipe = slapos.cookbook:slapconfiguration
14 15 16 17 18 19 20 21 22 23 24 25 26 27
computer = ${slap-connection:computer-id}
partition = ${slap-connection:partition-id}
url = ${slap-connection:server-url}
key = ${slap-connection:key-file}
cert = ${slap-connection:cert-file}

[slap-configuration]
# apache-frontend reads from from a part named [slap-configuration]
recipe = slapos.cookbook:slapconfiguration.serialised
computer = ${slap-connection:computer-id}
partition = ${slap-connection:partition-id}
url = ${slap-connection:server-url}
key = ${slap-connection:key-file}
cert = ${slap-connection:cert-file}
Jérome Perrin's avatar
Jérome Perrin committed
28 29 30 31 32 33 34 35

[directory]
recipe = slapos.cookbook:mkdirectory
home = ${buildout:directory}
etc = ${:home}/etc
var = ${:home}/var
srv = ${:home}/srv
service = ${:etc}/service
36
promise = ${:etc}/promise
Jérome Perrin's avatar
Jérome Perrin committed
37 38 39 40 41 42
influxdb-data-dir = ${:srv}/influxdb
grafana-dir = ${:srv}/grafana
grafana-data-dir = ${:grafana-dir}/data
grafana-logs-dir = ${:var}/log
grafana-plugins-dir = ${:grafana-dir}/plugins
grafana-provisioning-config-dir = ${:grafana-dir}/provisioning-config
43 44
grafana-provisioning-datasources-dir = ${:grafana-provisioning-config-dir}/datasources
grafana-provisioning-dashboards-dir = ${:grafana-provisioning-config-dir}/dashboards
Jérome Perrin's avatar
Jérome Perrin committed
45 46
telegraf-dir = ${:srv}/telegraf
telegraf-extra-config-dir = ${:telegraf-dir}/extra-config
47 48 49 50
loki-dir = ${:srv}/loki
loki-storage-boltdb-dir = ${:loki-dir}/index/
loki-storage-filesystem-dir = ${:loki-dir}/chunks/
promtail-dir = ${:srv}/promtail
Jérome Perrin's avatar
Jérome Perrin committed
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

# macros
[generate-certificate]
recipe = plone.recipe.command
command =
  if [ ! -e ${:key-file} ]
  then
    {{ openssl_bin }} req -x509 -nodes -days 3650 \
      -subj "/C=AA/ST=X/L=X/O=Dis/CN=${:common-name}" \
      -newkey rsa:1024 -keyout ${:key-file} \
      -out ${:cert-file}
  fi
update-command = ${:command}
key-file = ${directory:etc}/${:_buildout_section_name_}.key
cert-file = ${directory:etc}/${:_buildout_section_name_}.crt
common-name = ${:_buildout_section_name_}

[config-file]
recipe = slapos.recipe.template:jinja2
template = {{ buildout['parts-directory'] }}/${:_buildout_section_name_}/${:_buildout_section_name_}.cfg.in
rendered = ${directory:etc}/${:_buildout_section_name_}.cfg
mode = 0644
extensions = jinja2.ext.do

[check-port-listening-promise]
76 77
recipe = slapos.cookbook:check_port_listening
path = ${directory:promise}/${:_buildout_section_name_}
Jérome Perrin's avatar
Jérome Perrin committed
78

79 80 81 82 83
[check-url-available-promise]
recipe = slapos.cookbook:check_url_available
path = ${directory:promise}/${:_buildout_section_name_}
dash_path = {{ dash_bin }}
curl_path = {{ curl_bin }}
Jérome Perrin's avatar
Jérome Perrin committed
84 85 86

[influxdb]
ipv6 = ${instance-parameter:ipv6-random}
87
ipv4 = ${instance-parameter:ipv4-random}
Jérome Perrin's avatar
Jérome Perrin committed
88
host = ${:ipv6}
89 90
local-host = ${:ipv4}
rpc-port = 8088
Jérome Perrin's avatar
Jérome Perrin committed
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
http-port = 8086
url = https://[${:host}]:${:http-port}
data-dir = ${directory:influxdb-data-dir}
auth-username = ${influxdb-password:username}
auth-password = ${influxdb-password:passwd}
unix-socket = ${directory:var}/influxdb.socket
ssl-cert-file = ${influxdb-certificate:cert-file}
ssl-key-file = ${influxdb-certificate:key-file}
database = telegraf

recipe = slapos.cookbook:wrapper
command-line =
   nice -19 chrt --idle 0 ionice -c3 {{ influxd_bin }} -config ${influxdb-config-file:rendered}
wrapper-path = ${directory:service}/influxdb

[influxdb-config-file]
<= config-file
context =
  section influxdb influxdb

[influxdb-password]
recipe = slapos.cookbook:generate.password
username = influxdb

[influxdb-certificate]
<= generate-certificate

[influxdb-listen-promise]
<= check-port-listening-promise
120 121
hostname = ${influxdb:ipv6}
port = ${influxdb:http-port}
Jérome Perrin's avatar
Jérome Perrin committed
122 123

[influxdb-password-promise]
124 125
recipe = slapos.cookbook:wrapper
command-line =
Jérome Perrin's avatar
Jérome Perrin committed
126
  {{ influx_bin }} -username ${influxdb:auth-username} -password ${influxdb:auth-password} -socket ${influxdb:unix-socket} -execute "CREATE USER ${influxdb:auth-username} WITH PASSWORD '${influxdb:auth-password}' WITH ALL PRIVILEGES"
127
wrapper-path = ${directory:promise}/${:_buildout_section_name_}
Jérome Perrin's avatar
Jérome Perrin committed
128

129 130 131 132 133 134 135 136 137 138 139 140
[influxdb-database-ready-promise]
recipe = slapos.cookbook:wrapper
command-line =
  bash -c "{{ influx_bin }} \
     -username ${influxdb:auth-username} \
     -password ${influxdb:auth-password} \
     -host ${influxdb:host} \
     -port ${influxdb:http-port} \
     -unsafeSsl \
     -ssl \
     -execute 'show databases' | grep '${influxdb:database}'"
wrapper-path = ${directory:promise}/${:_buildout_section_name_}
Jérome Perrin's avatar
Jérome Perrin committed
141 142 143 144


[grafana]
ipv6 = ${instance-parameter:ipv6-random}
145
port = 8180
Jérome Perrin's avatar
Jérome Perrin committed
146 147 148 149 150 151
url = https://[${:ipv6}]:${:port}

data-dir = ${directory:grafana-data-dir}
logs-dir = ${directory:grafana-logs-dir}
plugins-dir = ${directory:grafana-plugins-dir}
provisioning-config-dir = ${directory:grafana-provisioning-config-dir}
152
provisioning-datasources-dir = ${directory:grafana-provisioning-datasources-dir}
Jérome Perrin's avatar
Jérome Perrin committed
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
admin-user = ${grafana-password:username}
admin-password = ${grafana-password:passwd}
secret-key = ${grafana-secret-key:passwd}
ssl-key-file = ${grafana-certificate:key-file}
ssl-cert-file = ${grafana-certificate:cert-file}

recipe = slapos.cookbook:wrapper
command-line =
    {{ grafana_bin }} -config ${grafana-config-file:rendered} -homepath {{ grafana_homepath }}
wrapper-path = ${directory:service}/grafana

[grafana-certificate]
<= generate-certificate

[grafana-password]
recipe = slapos.cookbook:generate.password
username = admin

[grafana-secret-key]
recipe = slapos.cookbook:generate.password

[grafana-config-file]
<= config-file
context =
  section grafana grafana
178
  section apache_frontend apache-frontend
179
  key slapparameter_dict slap-configuration:configuration
180 181 182 183 184 185 186 187 188
depends =
  ${grafana-provisioning-config-file:rendered}

[grafana-provisioning-config-file]
<= config-file
rendered = ${grafana:provisioning-datasources-dir}/datasource.yaml
context =
  section influxdb influxdb
  section loki loki
Jérome Perrin's avatar
Jérome Perrin committed
189 190 191

[grafana-listen-promise]
<= check-port-listening-promise
192 193
hostname= ${grafana:ipv6}
port = ${grafana:port}
Jérome Perrin's avatar
Jérome Perrin committed
194 195 196 197 198 199



[telegraf]
recipe = slapos.cookbook:wrapper
extra-config-dir = ${directory:telegraf-extra-config-dir}
200
# telegraf needs influxdb to be already listening before starting
Jérome Perrin's avatar
Jérome Perrin committed
201
command-line =
202
   bash -c '${influxdb-listen-promise:path} && nice -19 chrt --idle 0 ionice -c3 {{ telegraf_bin }} --config ${telegraf-config-file:rendered} --config-directory ${:extra-config-dir}'
Jérome Perrin's avatar
Jérome Perrin committed
203 204 205 206 207 208 209 210 211
wrapper-path = ${directory:service}/telegraf

[telegraf-config-file]
<= config-file
context =
  section influxdb influxdb
  section telegraf telegraf


212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
[loki]
recipe = slapos.cookbook:wrapper
command-line =
   bash -c 'nice -19 chrt --idle 0 ionice -c3 {{ loki_bin }} -config.file=${loki-config-file:rendered}'
wrapper-path = ${directory:service}/loki

storage-boltdb-dir = ${directory:loki-storage-boltdb-dir}
storage-filesystem-dir = ${directory:loki-storage-filesystem-dir}
ip = ${instance-parameter:ipv4-random}
port = 3100
url = http://${:ip}:${:port}


[loki-config-file]
<= config-file
context =
  section loki loki

[loki-listen-promise]
<= check-url-available-promise
url = ${loki:url}/ready

[promtail]
recipe = slapos.cookbook:wrapper
command-line =
   bash -c 'nice -19 chrt --idle 0 ionice -c3 {{ promtail_bin }} -config.file=${promtail-config-file:rendered}'
wrapper-path = ${directory:service}/promtail

dir = ${directory:promtail-dir}
http_port = 19080
ip = ${instance-parameter:ipv4-random}
url = http://${:ip}:${:http_port}

[promtail-config-file]
<= config-file
context =
  section promtail promtail
  section loki loki
  key slapparameter_dict slap-configuration:configuration

[promtail-listen-promise]
<= check-port-listening-promise
hostname= ${promtail:ip}
port = ${promtail:http_port}



259 260 261 262 263 264 265 266 267 268 269
[apache-frontend]
<= slap-connection
recipe = slapos.cookbook:requestoptional
name = Grafana Frontend
# XXX We have hardcoded SR URL here.
software-url = http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg
slave = true
config-url = ${grafana:url}
config-https-only = true
return = domain secure_access

270 271 272 273
[apache-frontend-available-promise]
<= check-url-available-promise
url = ${apache-frontend:connection-secure_access}

Jérome Perrin's avatar
Jérome Perrin committed
274 275 276 277 278 279

[promises]
recipe =
instance-promises =
  ${influxdb-listen-promise:path}
  ${influxdb-password-promise:wrapper-path}
280
  ${influxdb-database-ready-promise:wrapper-path}
Jérome Perrin's avatar
Jérome Perrin committed
281
  ${grafana-listen-promise:path}
282 283
  ${loki-listen-promise:path}
  ${promtail-listen-promise:path}
284 285
  ${promtail-listen-promise:path}
  ${apache-frontend-available-promise:path}
Jérome Perrin's avatar
Jérome Perrin committed
286 287 288 289 290 291 292 293 294


[publish-connection-parameter]
recipe = slapos.cookbook:publish
influxdb-url = ${influxdb:url}
influxdb-database = ${influxdb:database}
influxdb-username = ${influxdb:auth-username}
influxdb-password = ${influxdb:auth-password}
telegraf-extra-config-dir = ${telegraf:extra-config-dir}
295
grafana-url = ${grafana:url}
Jérome Perrin's avatar
Jérome Perrin committed
296 297
grafana-username = ${grafana:admin-user}
grafana-password = ${grafana:admin-password}
298 299
loki-url = ${loki:url}
promtail-url = ${promtail:url}
300
url = ${apache-frontend:connection-secure_access}