From c0eed0e9690e8a86828dfc439e46728d1dc3da66 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 12 Sep 2019 14:53:35 -0500 Subject: [PATCH] Add `rattail.deploy_machine_conf()` for basic machine-wide `rattail.conf` --- .../deploy/rattail/rattail.conf.mako | 100 ++++++++++++++++++ rattail_fabric2/rattail.py | 9 ++ 2 files changed, 109 insertions(+) create mode 100644 rattail_fabric2/deploy/rattail/rattail.conf.mako diff --git a/rattail_fabric2/deploy/rattail/rattail.conf.mako b/rattail_fabric2/deploy/rattail/rattail.conf.mako new file mode 100644 index 0000000..5653f51 --- /dev/null +++ b/rattail_fabric2/deploy/rattail/rattail.conf.mako @@ -0,0 +1,100 @@ +## -*- mode: conf; -*- + +${'#'}##################################################################### +# +# machine-wide rattail config +# +${'#'}##################################################################### + + +${'#'}############################# +# rattail +${'#'}############################# + +[rattail] +timezone.default = ${timezone} + +[rattail.config] +configure_logging = true + +[rattail.mail] +smtp.server = localhost +templates = rattail:templates/mail +default.from = root +default.to = root + + +${'#'}############################# +# logging +${'#'}############################# + +[loggers] +keys = root, exc_logger, beaker, txn, sqlalchemy, django_db, flufl_bounce, requests + +[handlers] +keys = file, console, email + +[formatters] +keys = generic, console + +[logger_root] +handlers = file, console +level = DEBUG + +[logger_exc_logger] +qualname = exc_logger +handlers = email +level = ERROR + +[logger_beaker] +qualname = beaker +handlers = +level = INFO + +[logger_txn] +qualname = txn +handlers = +level = INFO + +[logger_sqlalchemy] +qualname = sqlalchemy.engine +handlers = +# level = INFO + +[logger_django_db] +qualname = django.db.backends +handlers = +level = INFO + +[logger_flufl_bounce] +qualname = flufl.bounce +handlers = +level = WARNING + +[logger_requests] +qualname = requests +handlers = +# level = WARNING + +[handler_file] +class = handlers.WatchedFileHandler +args = ('rattail.log', 'a', 'utf_8') +formatter = generic + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +formatter = console + +[handler_email] +class = handlers.SMTPHandler +args = ('localhost', 'root', ['root'], "[Rattail] Logging") +formatter = generic +level = ERROR + +[formatter_generic] +format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(funcName)s: %(message)s +datefmt = %Y-%m-%d %H:%M:%S + +[formatter_console] +format = %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s diff --git a/rattail_fabric2/rattail.py b/rattail_fabric2/rattail.py index f5451f9..27e226e 100644 --- a/rattail_fabric2/rattail.py +++ b/rattail_fabric2/rattail.py @@ -56,6 +56,15 @@ def bootstrap_rattail(c, home='/var/lib/rattail', uid=None, shell='/bin/bash'): deploy(c, 'filemon', '/srv/rattail/init/filemon', use_sudo=True) +def deploy_machine_conf(c, timezone='America/Chicago'): + """ + Deploy the standard machine-wide ``rattail.conf`` file. + """ + mkdir(c, '/etc/rattail', use_sudo=True) + deploy(c, 'rattail/rattail.conf.mako', '/etc/rattail/rattail.conf', use_sudo=True, + context={'timezone': timezone}) + + def delete_email_recipients(c, dbname): """ Purge all email recipient settings for the given database.