mirror of
https://github.com/ansible/awx.git
synced 2026-05-11 03:17:38 -02:30
rename store_facts to use_fact_cache
This commit is contained in:
@@ -2227,7 +2227,7 @@ class JobOptionsSerializer(LabelsListMixin, BaseSerializer):
|
|||||||
fields = ('*', 'job_type', 'inventory', 'project', 'playbook',
|
fields = ('*', 'job_type', 'inventory', 'project', 'playbook',
|
||||||
'credential', 'vault_credential', 'forks', 'limit',
|
'credential', 'vault_credential', 'forks', 'limit',
|
||||||
'verbosity', 'extra_vars', 'job_tags', 'force_handlers',
|
'verbosity', 'extra_vars', 'job_tags', 'force_handlers',
|
||||||
'skip_tags', 'start_at_task', 'timeout', 'store_facts',)
|
'skip_tags', 'start_at_task', 'timeout', 'use_fact_cache',)
|
||||||
|
|
||||||
def get_fields(self):
|
def get_fields(self):
|
||||||
fields = super(JobOptionsSerializer, self).get_fields()
|
fields = super(JobOptionsSerializer, self).get_fields()
|
||||||
|
|||||||
@@ -88,13 +88,13 @@ class Migration(migrations.Migration):
|
|||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='job',
|
model_name='job',
|
||||||
name='store_facts',
|
name='use_fact_cache',
|
||||||
field=models.BooleanField(default=False, help_text='During a Job run, collect, associate, and persist the most recent per-Host Ansible facts in the ansible_facts namespace.'),
|
field=models.BooleanField(default=False, help_text='If enabled, Tower will act as an Ansible Fact Cache Plugin; persisting facts at the end of a playbook run to the database and caching facts for use by Ansible.'),
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='jobtemplate',
|
model_name='jobtemplate',
|
||||||
name='store_facts',
|
name='use_fact_cache',
|
||||||
field=models.BooleanField(default=False, help_text='During a Job run, collect, associate, and persist the most recent per-Host Ansible facts in the ansible_facts namespace.'),
|
field=models.BooleanField(default=False, help_text='If enabled, Tower will act as an Ansible Fact Cache Plugin; persisting facts at the end of a playbook run to the database and caching facts for use by Ansible.'),
|
||||||
),
|
),
|
||||||
migrations.RunSQL([("CREATE INDEX host_ansible_facts_default_gin ON %s USING gin"
|
migrations.RunSQL([("CREATE INDEX host_ansible_facts_default_gin ON %s USING gin"
|
||||||
"(ansible_facts jsonb_path_ops);", [AsIs(Host._meta.db_table)])],
|
"(ansible_facts jsonb_path_ops);", [AsIs(Host._meta.db_table)])],
|
||||||
|
|||||||
@@ -153,9 +153,9 @@ class JobOptions(BaseModel):
|
|||||||
default=0,
|
default=0,
|
||||||
help_text=_("The amount of time (in seconds) to run before the task is canceled."),
|
help_text=_("The amount of time (in seconds) to run before the task is canceled."),
|
||||||
)
|
)
|
||||||
store_facts = models.BooleanField(
|
use_fact_cache = models.BooleanField(
|
||||||
default=False,
|
default=False,
|
||||||
help_text=_('During a Job run, collect, associate, and persist the most recent per-Host Ansible facts in the ansible_facts namespace.'),
|
help_text=_("If enabled, Tower will act as an Ansible Fact Cache Plugin; persisting facts at the end of a playbook run to the database and caching facts for use by Ansible."),
|
||||||
)
|
)
|
||||||
|
|
||||||
extra_vars_dict = VarsDictProperty('extra_vars', True)
|
extra_vars_dict = VarsDictProperty('extra_vars', True)
|
||||||
@@ -288,7 +288,7 @@ class JobTemplate(UnifiedJobTemplate, JobOptions, SurveyJobTemplateMixin, Resour
|
|||||||
'schedule', 'limit', 'verbosity', 'job_tags', 'extra_vars',
|
'schedule', 'limit', 'verbosity', 'job_tags', 'extra_vars',
|
||||||
'launch_type', 'force_handlers', 'skip_tags', 'start_at_task',
|
'launch_type', 'force_handlers', 'skip_tags', 'start_at_task',
|
||||||
'become_enabled', 'labels', 'survey_passwords',
|
'become_enabled', 'labels', 'survey_passwords',
|
||||||
'allow_simultaneous', 'timeout', 'store_facts',]
|
'allow_simultaneous', 'timeout', 'use_fact_cache',]
|
||||||
|
|
||||||
def resource_validation_data(self):
|
def resource_validation_data(self):
|
||||||
'''
|
'''
|
||||||
|
|||||||
@@ -878,7 +878,7 @@ class RunJob(BaseTask):
|
|||||||
# callbacks to work.
|
# callbacks to work.
|
||||||
env['JOB_ID'] = str(job.pk)
|
env['JOB_ID'] = str(job.pk)
|
||||||
env['INVENTORY_ID'] = str(job.inventory.pk)
|
env['INVENTORY_ID'] = str(job.inventory.pk)
|
||||||
if job.store_facts:
|
if job.use_fact_cache:
|
||||||
env['ANSIBLE_LIBRARY'] = self.get_path_to('..', 'plugins', 'library')
|
env['ANSIBLE_LIBRARY'] = self.get_path_to('..', 'plugins', 'library')
|
||||||
env['ANSIBLE_CACHE_PLUGINS'] = self.get_path_to('..', 'plugins', 'fact_caching')
|
env['ANSIBLE_CACHE_PLUGINS'] = self.get_path_to('..', 'plugins', 'fact_caching')
|
||||||
env['ANSIBLE_CACHE_PLUGIN'] = "tower"
|
env['ANSIBLE_CACHE_PLUGIN'] = "tower"
|
||||||
@@ -1140,13 +1140,13 @@ class RunJob(BaseTask):
|
|||||||
('project_update', local_project_sync.name, local_project_sync.id)))
|
('project_update', local_project_sync.name, local_project_sync.id)))
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if job.store_facts:
|
if job.use_fact_cache:
|
||||||
job.start_job_fact_cache()
|
job.start_job_fact_cache()
|
||||||
|
|
||||||
|
|
||||||
def final_run_hook(self, job, status, **kwargs):
|
def final_run_hook(self, job, status, **kwargs):
|
||||||
super(RunJob, self).final_run_hook(job, status, **kwargs)
|
super(RunJob, self).final_run_hook(job, status, **kwargs)
|
||||||
if job.store_facts:
|
if job.use_fact_cache:
|
||||||
job.finish_job_fact_cache()
|
job.finish_job_fact_cache()
|
||||||
try:
|
try:
|
||||||
inventory = job.inventory
|
inventory = job.inventory
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import socket
|
|||||||
import select
|
import select
|
||||||
import six
|
import six
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
from copy import copy
|
|
||||||
from requests.exceptions import RequestException
|
from requests.exceptions import RequestException
|
||||||
|
|
||||||
# loggly
|
# loggly
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from `InventorySource` completely in Tower 3.3. As a result the related field on
|
|||||||
|
|
||||||
## Fact Searching
|
## Fact Searching
|
||||||
Facts generated by an Ansible playbook during a Job Template run are stored by Tower into the database
|
Facts generated by an Ansible playbook during a Job Template run are stored by Tower into the database
|
||||||
whenever `store_facts=True` is set per-Job-Template. New facts are merged with existing
|
whenever `use_fact_cache=True` is set per-Job-Template. New facts are merged with existing
|
||||||
facts and are per-host. These stored facts can be used to filter hosts via the
|
facts and are per-host. These stored facts can be used to filter hosts via the
|
||||||
`/api/v2/hosts` endpoint, using the GET query parameter `host_filter` i.e.
|
`/api/v2/hosts` endpoint, using the GET query parameter `host_filter` i.e.
|
||||||
`/api/v2/hosts?host_filter=ansible_facts__ansible_processor_vcpus=8`
|
`/api/v2/hosts?host_filter=ansible_facts__ansible_processor_vcpus=8`
|
||||||
|
|||||||
Reference in New Issue
Block a user