Merge lp:~tcuthbert/charm-haproxy/trunk into lp:charm-haproxy

Proposed by Thomas Cuthbert
Status: Merged
Approved by: Nick Moffitt
Approved revision: 134
Merged at revision: 134
Proposed branch: lp:~tcuthbert/charm-haproxy/trunk
Merge into: lp:charm-haproxy
Diff against target: 60 lines (+18/-0)
2 files modified
config.yaml (+4/-0)
hooks/hooks.py (+14/-0)
To merge this branch: bzr merge lp:~tcuthbert/charm-haproxy/trunk
Reviewer Review Type Date Requested Status
Canonical IS Reviewers Pending
haproxy-team Pending
Review via email: mp+368527@code.launchpad.net

Commit message

Add custom logrotate configuration option, LP#1673011

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 134

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2019-05-17 14:20:57 +0000
3+++ config.yaml 2019-06-07 09:24:54 +0000
4@@ -94,6 +94,10 @@
5 default: "queue 20000, client 50000, connect 5000, server 50000"
6 type: string
7 description: Default timeouts
8+ logrotate_config:
9+ default: ""
10+ type: string
11+ description: Override package logrotate configuration.
12 enable_monitoring:
13 default: False
14 type: boolean
15
16=== modified file 'hooks/hooks.py'
17--- hooks/hooks.py 2019-05-17 14:38:23 +0000
18+++ hooks/hooks.py 2019-06-07 09:24:54 +0000
19@@ -52,6 +52,7 @@
20 default_haproxy_lib_dir = "/var/lib/haproxy"
21 metrics_cronjob_path = "/etc/cron.d/haproxy_metrics"
22 metrics_script_path = "/usr/local/bin/haproxy_to_statsd.sh"
23+log_rotate_config_path = "/etc/logrotate.d/haproxy"
24 service_affecting_packages = ['haproxy']
25 apt_backports_template = (
26 "deb http://archive.ubuntu.com/ubuntu %(release)s-backports "
27@@ -961,6 +962,9 @@
28 ensure_package_status(service_affecting_packages, config_data['package_status'])
29 enable_haproxy()
30
31+ if config_data.get('logrotate_config'):
32+ logrotate_configuration()
33+
34
35 def config_changed():
36 config_data = config_get()
37@@ -978,6 +982,9 @@
38 else:
39 raise ValueError('{} is not a valid port/proto value'.format(port_plus_proto))
40
41+ if config_data.changed('logrotate_config'):
42+ logrotate_configuration()
43+
44 old_stanzas = get_listen_stanzas()
45 haproxy_globals = create_haproxy_globals()
46 haproxy_userlists = create_haproxy_userlists()
47@@ -1388,6 +1395,13 @@
48 user=monitoring_username)
49
50
51+def logrotate_configuration():
52+ config = config_get()
53+ logrotate_config = config['logrotate_config']
54+ with open(log_rotate_config_path, 'w') as f:
55+ f.write(logrotate_config)
56+
57+
58 # #############################################################################
59 # Main section
60 # #############################################################################

Subscribers

People subscribed via source and target branches

to all changes: