tower fact cache implementation

* Tower now injects facts into jobs via memcached for use by Ansible
playbooks. On the Ansible side, this is accomplished by the existing
mechanism, an Ansible Fact Cache Plugin + memcached. On the Tower side,
memcached is leveraged heavily.
This commit is contained in:
Chris Meyers
2017-06-13 12:41:35 -04:00
parent 0121f5cde4
commit 626e2d1c9b
4 changed files with 232 additions and 68 deletions

View File

@@ -877,6 +877,9 @@ class RunJob(BaseTask):
# callbacks to work.
env['JOB_ID'] = str(job.pk)
env['INVENTORY_ID'] = str(job.inventory.pk)
if job.store_facts_enabled:
env['MEMCACHED_PREPEND_KEY'] = job.memcached_fact_key
env['MEMCACHED_LOCATION'] = settings.CACHES['default']['LOCATION']
if job.project:
env['PROJECT_REVISION'] = job.project.scm_revision
env['ANSIBLE_RETRY_FILES_ENABLED'] = "False"
@@ -1140,8 +1143,14 @@ class RunJob(BaseTask):
('project_update', local_project_sync.name, local_project_sync.id)))
raise
if job.store_facts_enabled:
job.start_job_fact_cache()
def final_run_hook(self, job, status, **kwargs):
super(RunJob, self).final_run_hook(job, status, **kwargs)
if job.store_facts_enabled:
job.finish_job_fact_cache()
try:
inventory = job.inventory
except Inventory.DoesNotExist: