instance-logrotate-base.cfg.in 3.16 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 51
# - "copytruncate" to use logrotate's copytruncate option, setting to ""
#    (the default) disable copytruncate, setting to anything else enable copytruncate
52
recipe = slapos.recipe.template:jinja2
53 54
url = {{ logrotate_entry_template }}
output = ${logrotate-conf-parameter:logrotate-entries}/${:name}
55
context =
56
  key backup :backup
57
  key log :log
58
  key copytruncate :copytruncate
59 60
  key post :post
  key pre :pre
61 62 63
  key frequency :frequency
  key rotate_num :rotate-num
  key nocompress :nocompress
64
  key delaycompress :delaycompress
65
copytruncate =
66 67
post =
pre =
68 69
frequency = daily
rotate-num = 3650
70
backup = ${logrotate-directory:logrotate-backup}
71
nocompress =
72
delaycompress = true
73 74 75

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

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

86 87 88 89 90
[logrotate-entry-cron]
<= logrotate-entry-base
name = crond
log = ${cron-simplelogger:log}

91 92 93 94 95 96 97 98 99 100 101
[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
102
services = ${:etc}/service
103
log = ${buildout:directory}/var/log