Support a way for fact collectors to depend on other collectors #31006
Labels
affects_2.5
This issue/PR affects Ansible v2.5
feature
This issue/PR relates to a feature request.
support:core
This issue/PR relates to code supported by the Ansible Engineering Team.
COMPONENT NAME
lib/ansible/module_utils/facts/
SUMMARY
Allow fact collectors to indicate if they need information from another fact collector to be gathered first.
Some fact collectors require information to be gathered by other fact collections before they run, so
we need to be able to order the collector runs. To do this, the fact collectors need a way to indicate their dependencies, and the ansible_collector used by setup.py needs to understand how to use that info.
ie, a fact collector dep solver more or less.
The most common case for this is collectors that need to know the systems platform infomation ('ansible_system', 'ansible_machine, 'ansible_distribution', etc). But for custom fact collection modules, there may be other cases (some of the openshift fact collectors depend on other openshift collectors
for example).
possible implementations
collectors would indicate their deps so they could be resolved and topological sorted so dependent collectors always run before depending collectors.
A wip / proof of concept branch exists at devel...alikins:fact_collector_ordering_gather_spec
Since the number of collectors with dependencies is small (at least in default ansible facts) it may be simple just to specify an explicit ordering to run collectors in. Custom fact collectors would also need to be able to specify this.
possible alternatives
For the default set of facts, this is probably doable. There is a small number of deps, and most are platform infomation requirements. Since there is already support for choosing the implementation of a fact collector based on system platform information, most/all of the deps could be eliminated.
But for collector ordering deps that depend on other info (like the openshift fact modules), this may not be doable.
EXPECTED RESULTS
ACTUAL RESULTS
The text was updated successfully, but these errors were encountered: