Skip to content

Latest commit

 

History

History
43 lines (37 loc) · 2.29 KB

fact_cache.md

File metadata and controls

43 lines (37 loc) · 2.29 KB

Ascender as an Ansible Fact Cache

Ascender can store and retrieve per-host facts via an Ansible Fact Cache Plugin. This behavior is configurable on a per-job-template basis. When enabled, Ascender will serve fact requests for all Hosts in an Inventory related to the Job running. This allows users to use Job Templates with --limit while still having access to the entire Inventory of Host facts.

Ascender Fact Cache Implementation Details

Ascender Injection

In order to understand the behavior of Ascender as a fact cache, you will need to understand how fact caching is achieved in Ascender. When a Job launches with use_fact_cache=True, Ascender will write all ansible_facts associated with each Host in the associated Inventory as JSON files on the local file system (one JSON file per host). Jobs invoked with use_fact_cache=False will not write ansible_facts files.

Ansible Plugin Usage

When use_fact_cache=True, Ansible will be configured to use the jsonfile cache plugin. Any get() call to the fact cache interface in Ansible will result in a JSON file lookup for the host-specific set of facts. Any set() call to the fact cache will result in a JSON file being written to the local file system.

Ascender Cache to DB

When a Job with use_fact_cache=True finishes running, Ascender will look at all of the local JSON files that represent the fact data. Any records with file modification times that have increased (because Ansible updated the file via cache.set()) will result in the latest value being saved to the database. On subsequent playbook runs, Ascender will only inject cached facts that are newer than settings.ANSIBLE_FACT_CACHE_TIMEOUT seconds.

Ascender Fact Logging

New and changed facts will be logged via Ascender's logging facility, specifically to the system_tracking namespace or logger. The logging payload will include the fields host_name, inventory_id, and ansible_facts. Where ansible_facts is a dictionary of all Ansible facts for host_name in Ascender Inventory inventory_id.

Integration Testing

  • Ensure clear_facts sets hosts/<id>/ansible_facts to {}.
  • Ensure that gather_facts: False does NOT result in clearing existing facts.
  • Ensure that when a host fact timeout is reached, that the facts are not used from the cache.