mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 10:30:03 -03:30
Merge pull request #1306 from ryanpetrello/isolated-fact-cache
support fact caching for isolated hosts
This commit is contained in:
commit
7db05855de
@ -901,7 +901,7 @@ class BaseTask(LogErrorsTask):
|
||||
|
||||
# Fetch "cached" fact data from prior runs and put on the disk
|
||||
# where ansible expects to find it
|
||||
if getattr(instance, 'use_fact_cache', False) and not kwargs.get('isolated'):
|
||||
if getattr(instance, 'use_fact_cache', False):
|
||||
instance.start_job_fact_cache(
|
||||
os.path.join(kwargs['private_data_dir']),
|
||||
kwargs.setdefault('fact_modification_times', {})
|
||||
@ -1140,7 +1140,7 @@ class RunJob(BaseTask):
|
||||
# callbacks to work.
|
||||
env['JOB_ID'] = str(job.pk)
|
||||
env['INVENTORY_ID'] = str(job.inventory.pk)
|
||||
if job.use_fact_cache and not kwargs.get('isolated'):
|
||||
if job.use_fact_cache:
|
||||
library_path = env.get('ANSIBLE_LIBRARY')
|
||||
env['ANSIBLE_LIBRARY'] = ':'.join(
|
||||
filter(None, [
|
||||
@ -1349,7 +1349,7 @@ class RunJob(BaseTask):
|
||||
|
||||
def final_run_hook(self, job, status, **kwargs):
|
||||
super(RunJob, self).final_run_hook(job, status, **kwargs)
|
||||
if job.use_fact_cache and not kwargs.get('isolated'):
|
||||
if job.use_fact_cache:
|
||||
job.finish_job_fact_cache(
|
||||
kwargs['private_data_dir'],
|
||||
kwargs['fact_modification_times']
|
||||
|
||||
@ -25,3 +25,14 @@
|
||||
fail:
|
||||
msg: "isolated task is still running"
|
||||
when: "is_alive.rc == 0"
|
||||
|
||||
- stat: path="{{src}}/facts/"
|
||||
register: fact_cache
|
||||
|
||||
- name: Copy gathered facts from the isolated host.
|
||||
synchronize:
|
||||
src: "{{src}}/facts/"
|
||||
dest: "{{src}}/facts/"
|
||||
delete: yes # delete fact cache records that go missing via clear_facts
|
||||
mode: pull
|
||||
when: fact_cache.stat.exists
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user