instance-logrotate-base.cfg.in 2.96 KB
Newer Older
1 2
[buildout]
parts =
3
  cron-service
4
  cron-entry-logrotate
5
  logrotate-entry-cron
6 7 8 9 10 11 12 13

[cron]
recipe = slapos.cookbook:cron
cron-entries = ${logrotate-directory:cron-entries}
dcrond-binary = {{ dcron_location }}/sbin/crond
crontabs = ${logrotate-directory:crontabs}
cronstamps = ${logrotate-directory:cronstamps}
catcher = ${cron-simplelogger:wrapper}
14 15 16 17 18 19 20 21 22
binary = ${logrotate-directory:bin}/crond
# This is here so to keep backward compatibility where the cron
# section should create the service too and keep variables here
service = ${cron-service:wrapper-path}

[cron-service]
recipe = slapos.cookbook:wrapper
command-line = ${cron:binary}
wrapper-path = ${logrotate-directory:services}/crond
23
hash-existing-files = ${buildout:directory}/software_release/buildout.cfg
24 25 26 27 28 29

[cron-simplelogger]
recipe = slapos.cookbook:simplelogger
wrapper = ${logrotate-directory:bin}/cron_simplelogger
log = ${logrotate-directory:log}/cron.log

30
[logrotate-conf-parameter]
31 32
compress-binary = {{ xz_location }}/bin/xz
uncompress-binary = {{ xz_location }}/bin/unxz
33 34 35 36
logrotate-entries = ${logrotate-directory:logrotate-entries}

[logrotate-conf]
recipe = slapos.recipe.template:jinja2
37 38
url = {{ logrotate_conf_template }}
output = ${logrotate-directory:etc}/logrotate.conf
39 40 41 42 43 44 45 46 47 48
context =
  section parameter_dict logrotate-conf-parameter

[logrotate-entry-base]
# User must define keys:
# - "name" to generate configuration path (must be unique in partition)
# - "log" space-separated list of file paths to be rotated
# User may override keys:
# - "post" with commands to execute after rotation
# - "pre" with commands to execute before rotation
49
# - "backup" with directory where to store logs
50
recipe = slapos.recipe.template:jinja2
51 52
url = {{ logrotate_entry_template }}
output = ${logrotate-conf-parameter:logrotate-entries}/${:name}
53
context =
54
  key backup :backup
55 56 57
  key log :log
  key post :post
  key pre :pre
58 59 60
  key frequency :frequency
  key rotate_num :rotate-num
  key nocompress :nocompress
61
  key delaycompress :delaycompress
62 63
post =
pre =
64 65
frequency = daily
rotate-num = 3650
66
backup = ${logrotate-directory:logrotate-backup}
67
nocompress =
68
delaycompress = true
69 70 71

[logrotate]
recipe = slapos.cookbook:wrapper
72
command-line = {{ logrotate_location }}/sbin/logrotate -s "${logrotate-directory:srv}/logrotate.status" "${logrotate-conf:output}"
73
wrapper-path = ${logrotate-directory:bin}/logrotate
74 75 76 77 78 79

[cron-entry-logrotate]
recipe = slapos.cookbook:cron.d
cron-entries = ${cron:cron-entries}
name = logrotate
frequency = 0 0 * * *
80
command = ${logrotate:wrapper-path}
81

82 83 84 85 86
[logrotate-entry-cron]
<= logrotate-entry-base
name = crond
log = ${cron-simplelogger:log}

87 88 89 90 91 92 93 94 95 96 97
[logrotate-directory]
recipe = slapos.cookbook:mkdirectory
cron-entries = ${:etc}/cron.d
cronstamps = ${:etc}/cronstamps
crontabs = ${:etc}/crontabs
logrotate-backup = ${:backup}/logrotate
logrotate-entries = ${:etc}/logrotate.d
bin = ${buildout:directory}/bin
srv = ${buildout:directory}/srv
backup = ${:srv}/backup
etc = ${buildout:directory}/etc
98
services = ${:etc}/service
99
log = ${buildout:directory}/var/log