launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #28315
[Merge] ~cjwatson/rutabaga:charm-fix-template-expansion into rutabaga:master
Colin Watson has proposed merging ~cjwatson/rutabaga:charm-fix-template-expansion into rutabaga:master.
Commit message:
charm: Fix expansion of logrotate and crontab templates
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/rutabaga/+git/rutabaga/+merge/418939
We weren't setting all the context variables that they need, so the resulting files were broken.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/rutabaga:charm-fix-template-expansion into rutabaga:master.
diff --git a/charm/rutabaga/lib/charms/rutabaga.py b/charm/rutabaga/lib/charms/rutabaga.py
index ab67a3d..6d4d6d3 100644
--- a/charm/rutabaga/lib/charms/rutabaga.py
+++ b/charm/rutabaga/lib/charms/rutabaga.py
@@ -256,8 +256,10 @@ def configure_wsgi():
def configure_logrotate():
hookenv.log('Writing logrotate configuration.')
config = hookenv.config()
+ context = dict(config)
+ context['logs_dir'] = logs_dir()
templating.render(
- 'logrotate.conf.j2', '/etc/logrotate.d/rutabaga', config, perms=0o644)
+ 'logrotate.conf.j2', '/etc/logrotate.d/rutabaga', context, perms=0o644)
def configure_rsync():
@@ -276,8 +278,15 @@ def configure_rsync():
def configure_cron():
hookenv.log('Writing crontab.')
config = hookenv.config()
+ context = dict(config)
+ context.update({
+ 'code_dir': code_dir(),
+ 'db_dir': db_dir(),
+ 'logs_dir': logs_dir(),
+ 'venv_dir': venv_dir(),
+ })
templating.render(
- 'crontab.j2', '/etc/cron.d/rutabaga', config, perms=0o644)
+ 'crontab.j2', '/etc/cron.d/rutabaga', context, perms=0o644)
def add_nagios_proxy_check(nagios, squid):
diff --git a/charm/rutabaga/templates/crontab.j2 b/charm/rutabaga/templates/crontab.j2
index 6a969ee..013f2ad 100644
--- a/charm/rutabaga/templates/crontab.j2
+++ b/charm/rutabaga/templates/crontab.j2
@@ -1,2 +1,2 @@
-*/{{ token_purge_minutes }} * * * * root DATABASE={{ database }} TOKEN_TTL_MINUTES={{ token_ttl_minutes }} {{ venv_dir }}/bin/python3 {{ code_dir }}/rutabaga/scripts/purge.py >>{{ logs_dir }}/rutabaga-purge.log 2>&1
+*/{{ token_purge_minutes }} * * * * root DATABASE={{ db_dir }}/rutabaga.db TOKEN_TTL_MINUTES={{ token_ttl_minutes }} {{ venv_dir }}/bin/python3 {{ code_dir }}/rutabaga/scripts/purge.py >>{{ logs_dir }}/rutabaga-purge.log 2>&1