Need help understanding the differences and limitations of:
- Play-level gather_facts
- Explicit
ansible.builtin.gather_facts
- Explicit
ansible.builtin.setup
From observation it seems that ansible.builtin.gather_facts is either not aware of or does not honor the play-level use of fact_path. Is that accurate? If we want to perform explicit gathering of facts, within a play, would we need to use ansible.builtin.setup with the fact_path option even if fact_path is set as a play-level keyword?
For background we need to gather cusom Windows facts, from a PS1 script, deployed to remote instances.
@gundalow would you have any insight on this?
gather_facts can include calling multiple mouldes, controlled by this config var. Ansible Configuration Settings — Ansible Community Documentation
By default, calling gsther_facts will call the setup module. In theory you could call other modules too, all with a single gather_facts module
I have not used that myself, so that’s about as much as I can say.
I’ve gathered custom facts of windows before, and noticed that calling gather_facts with a fact_path attribute means only the custom facts at that path are collected. On Linux, all facts are gathered even if fact_path is defined (iirc)
When I did this on windows, I did a regular gather facts at the playbook level. Then as a pre task, I did a facts_gather and specified the facts_path to get the custom facts