From b9fe359d2357b07931535340dabc54232ac27c2d Mon Sep 17 00:00:00 2001 From: kevgliss Date: Mon, 25 Apr 2016 11:21:25 -0700 Subject: [PATCH] Fixes #285 Renames sync_sources function to sync to align documentation. --- docs/administration.rst | 19 ++++++++++++++----- docs/production/index.rst | 22 ++++++++++++++++++++++ docs/quickstart/index.rst | 7 ++++--- lemur/manage.py | 8 ++++---- 4 files changed, 44 insertions(+), 12 deletions(-) diff --git a/docs/administration.rst b/docs/administration.rst index 110c6837..5884eef5 100644 --- a/docs/administration.rst +++ b/docs/administration.rst @@ -588,24 +588,33 @@ All commands default to `~/.lemur/lemur.conf.py` if a configuration is not speci Traverses every certificate that Lemur is aware of and attempts to understand its validity. It utilizes both OCSP and CRL. If Lemur is unable to come to a conclusion about a certificates - validity its status is marked 'unknown' + validity its status is marked 'unknown'. .. data:: sync Sync attempts to discover certificates in the environment that were not created by Lemur. If you wish to only sync - a few sources you can pass a comma delimited list of sources to sync + a few sources you can pass a comma delimited list of sources to sync. :: - lemur sync source1,source2 + lemur sync -s source1,source2 - Additionally you can also list the available sources that Lemur can sync + Additionally you can also list the available sources that Lemur can sync. :: - lemur sync -list + lemur sync + + +.. data:: notify + + Will traverse all current notifications and see if any of them need to be triggered. + + :: + + lemur notify Sub-commands diff --git a/docs/production/index.rst b/docs/production/index.rst index 2dff5b84..5868fafb 100644 --- a/docs/production/index.rst +++ b/docs/production/index.rst @@ -295,3 +295,25 @@ Then you can manage the process by running:: It will start a shell from which you can start/stop/restart the service. You can read all errors that might occur from /tmp/lemur.log. + + +Periodic Tasks +============== + +Lemur contains a few tasks that are run and scheduled basis, currently the recommend way to run these tasks is to create +a cron job that runs the commands. + +There are currently three commands that could/should be run on a periodic basis: + +- `notify` +- `check_revoked` +- `sync` + +How often you run these commands is largely up to the user. `notify` and `check_revoked` are typically run at least once a day. +`sync` is typically run every 15 minutes. + +Example cron entries:: + + 0 22 * * * lemuruser export LEMUR_CONF=/Users/me/.lemur/lemur.conf.py; /www/lemur/bin/lemur notify + */15 * * * * lemuruser export LEMUR_CONF=/Users/me/.lemur/lemur.conf.py; /www/lemur/bin/lemur sync -s all + 0 22 * * * lemuruser export LEMUR_CONF=/Users/me/.lemur/lemur.conf.py; /www/lemur/bin/lemur check_revoked \ No newline at end of file diff --git a/docs/quickstart/index.rst b/docs/quickstart/index.rst index 7dcaca2b..1f1ad68c 100644 --- a/docs/quickstart/index.rst +++ b/docs/quickstart/index.rst @@ -243,13 +243,14 @@ See :ref:`Using Supervisor ` for more details on using Supervis Syncing ------- -Lemur uses periodic sync tasks to make sure it is up-to-date with its environment. As always, things can change outside of Lemur, but we do our best to reconcile those changes, for example, using Cron: +Lemur uses periodic sync tasks to make sure it is up-to-date with its environment. Things change outside of Lemur we do our best to reconcile those changes. The recommended method is to use CRON: .. code-block:: bash $ crontab -e - * 3 * * * lemur sync --all - * 3 * * * lemur check_revoked + */15 * * * * lemur sync -s all + 0 22 * * * lemur check_revoked + 0 22 * * * lemur notify Additional Utilities diff --git a/lemur/manage.py b/lemur/manage.py index 0316ba56..4e35d605 100755 --- a/lemur/manage.py +++ b/lemur/manage.py @@ -30,7 +30,7 @@ from lemur.certificates.verify import verify_string from lemur.plugins.lemur_aws import elb -from lemur.sources.service import sync +from lemur.sources.service import sync as source_sync from lemur import create_app @@ -189,7 +189,7 @@ def generate_settings(): @manager.option('-s', '--sources', dest='labels') -def sync_sources(labels): +def sync(labels): """ Attempts to run several methods Certificate discovery. This is run on a periodic basis and updates the Lemur datastore with the @@ -218,9 +218,9 @@ def sync_sources(labels): labels = labels.split(",") if labels[0] == 'all': - sync() + source_sync() else: - sync(labels=labels) + source_sync(labels=labels) sys.stdout.write( "[+] Finished syncing sources. Run Time: {time}\n".format(