instance-logrotate-base.cfg.in 2.92 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 37 38 39 40 41 42 43 44 45 46 47 48
logrotate-entries = ${logrotate-directory:logrotate-entries}

[logrotate-conf]
recipe = slapos.recipe.template:jinja2
template = {{ logrotate_conf_template }}
rendered = ${logrotate-directory:etc}/logrotate.conf
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 51 52 53
recipe = slapos.recipe.template:jinja2
template = {{ logrotate_entry_template }}
rendered = ${logrotate-conf-parameter:logrotate-entries}/${:name}
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 62
post =
pre =
63 64
frequency = daily
rotate-num = 3650
65
backup = ${logrotate-directory:logrotate-backup}
66
nocompress =
67 68 69

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

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

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

85 86 87 88 89 90 91 92 93 94 95
[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
96
services = ${:etc}/service
97
log = ${buildout:directory}/var/log