From 965159a1fbc1e18dbaba589d5919752f662b0d50 Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Mon, 19 Jun 2017 15:45:32 -0400 Subject: [PATCH] rename store_facts to use_fact_cache --- awx/api/serializers.py | 2 +- awx/main/migrations/0038_v320_release.py | 8 ++++---- awx/main/models/jobs.py | 6 +++--- awx/main/tasks.py | 6 +++--- awx/main/utils/handlers.py | 1 - docs/inventory_refresh.md | 2 +- 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/awx/api/serializers.py b/awx/api/serializers.py index 3c8ae05c75..38dd74702d 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -2227,7 +2227,7 @@ class JobOptionsSerializer(LabelsListMixin, BaseSerializer): fields = ('*', 'job_type', 'inventory', 'project', 'playbook', 'credential', 'vault_credential', 'forks', 'limit', '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): fields = super(JobOptionsSerializer, self).get_fields() diff --git a/awx/main/migrations/0038_v320_release.py b/awx/main/migrations/0038_v320_release.py index f04d280727..16f9ce1688 100644 --- a/awx/main/migrations/0038_v320_release.py +++ b/awx/main/migrations/0038_v320_release.py @@ -88,13 +88,13 @@ class Migration(migrations.Migration): ), migrations.AddField( model_name='job', - name='store_facts', - 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.'), + name='use_fact_cache', + 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( model_name='jobtemplate', - name='store_facts', - 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.'), + name='use_fact_cache', + 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" "(ansible_facts jsonb_path_ops);", [AsIs(Host._meta.db_table)])], diff --git a/awx/main/models/jobs.py b/awx/main/models/jobs.py index 31952ae952..6ac43cc98a 100644 --- a/awx/main/models/jobs.py +++ b/awx/main/models/jobs.py @@ -153,9 +153,9 @@ class JobOptions(BaseModel): default=0, 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, - 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) @@ -288,7 +288,7 @@ class JobTemplate(UnifiedJobTemplate, JobOptions, SurveyJobTemplateMixin, Resour 'schedule', 'limit', 'verbosity', 'job_tags', 'extra_vars', 'launch_type', 'force_handlers', 'skip_tags', 'start_at_task', 'become_enabled', 'labels', 'survey_passwords', - 'allow_simultaneous', 'timeout', 'store_facts',] + 'allow_simultaneous', 'timeout', 'use_fact_cache',] def resource_validation_data(self): ''' diff --git a/awx/main/tasks.py b/awx/main/tasks.py index dd344ea587..c2b4af4b77 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -878,7 +878,7 @@ class RunJob(BaseTask): # callbacks to work. env['JOB_ID'] = str(job.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_CACHE_PLUGINS'] = self.get_path_to('..', 'plugins', 'fact_caching') env['ANSIBLE_CACHE_PLUGIN'] = "tower" @@ -1140,13 +1140,13 @@ class RunJob(BaseTask): ('project_update', local_project_sync.name, local_project_sync.id))) raise - if job.store_facts: + if job.use_fact_cache: 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: + if job.use_fact_cache: job.finish_job_fact_cache() try: inventory = job.inventory diff --git a/awx/main/utils/handlers.py b/awx/main/utils/handlers.py index 3cdbbb261a..8103f910b4 100644 --- a/awx/main/utils/handlers.py +++ b/awx/main/utils/handlers.py @@ -11,7 +11,6 @@ import socket import select import six from concurrent.futures import ThreadPoolExecutor -from copy import copy from requests.exceptions import RequestException # loggly diff --git a/docs/inventory_refresh.md b/docs/inventory_refresh.md index e5840c8bbe..ae58cf9c7b 100644 --- a/docs/inventory_refresh.md +++ b/docs/inventory_refresh.md @@ -13,7 +13,7 @@ from `InventorySource` completely in Tower 3.3. As a result the related field on ## Fact Searching 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 `/api/v2/hosts` endpoint, using the GET query parameter `host_filter` i.e. `/api/v2/hosts?host_filter=ansible_facts__ansible_processor_vcpus=8`