chocolatey / chocolatey-ansible

The Chocolatey module collection for Ansible
GNU General Public License v3.0
47 stars 29 forks source link

win_chocolatey_facts - add `filter` / `gather_subset` option #108

Closed steviecoaster closed 1 year ago

steviecoaster commented 1 year ago

Currently, the win_chocolatey_facts module gathers the following items:

This causes a large performance hit to fact gathering, especially running choco oudated every single time, particularly on hosts with a large number of Chocolatey packages installed.

Ansible has added the concept of a subset of facts to collect during gathering, which you can control with filters. Examples of this can be found in their documentation available here.

I propose that in our win_chocolatey.facts module we provide the same mechanism such that we could do something similar to the following:

- name: Gather facts
  win_chocolatey_facts:
    gather_subset:
    - config
    - features
    - sources
    - !packages
    - !outdated

The example above would only gather the facts for config, features, sources.