The ansible_local var is not being populated when using the setup module to gather custom facts on windows The ansible_local var is not being populated when using the setup module to gather custom facts on windows.
Playbook:
---
- name: Testing and Debug PB
  hosts: all
  tasks:
  
    - name: Gather Facts
      setup:
        fact_path: 'c:\custom_facts'

    - debug:
        msg: &quot;{{ hostvars[inventory_hostname] }}&quot;

    - debug:
        msg: &quot;{{ ansible_local }}&quot;

Contents of &quot;C:\custom_facts\foo.fact&quot; on remote host:
[general]
asdf=1
bar=2

Playbook Output:
ansible-playbook -i inv/dev 301_pb_testing.yml -vv
ansible-playbook 2.9.12
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/alex/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/dist-packages/ansible
  executable location = /usr/local/bin/ansible-playbook
  python version = 3.6.9 (default, Jul 17 2020, 12:50:27) [GCC 8.4.0]
Using /etc/ansible/ansible.cfg as config file

PLAYBOOK: 301_pb_testing.yml ************************************************************************************************************************************************1 plays in 301_pb_testing.yml

PLAY [Testing and Debug PB] *************************************************************************************************************************************************
TASK [Gathering Facts] ******************************************************************************************************************************************************task path: /home/alex/git.sigma/SDG-Tech-DevOps/ansible/301_pb_testing.yml:2
ok: [demi-win00]
META: ran handlers

TASK [facts : Gather Facts] *************************************************************************************************************************************************task path: /home/alex/git.sigma/SDG-Tech-DevOps/ansible/roles/facts/tasks/main.yml:14
ok: [demi-win00]

TASK [debug] ****************************************************************************************************************************************************************task path: /home/alex/git.sigma/SDG-Tech-DevOps/ansible/301_pb_testing.yml:15

---------REMOVED SOME HOSTVAR OUTPUT FOR BREVITY AND PRIVACY--------

ok: [demi-win00] =&gt; 
  msg: |-
    ansible_architecture: 64-bit
    ansible_bios_date: 03/31/2014
    ansible_bios_version: rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org
    ansible_check_mode: false
    ansible_connection: winrm
    ansible_date_time:
  ......
    ansible_facts:
   ......
    ansible_kernel: 10.0.17763.0
    ansible_lastboot: '2020-08-29 11:07:46Z'
    ansible_machine_id: S-1-5-21-49790847-4020553596-361474921
   ......

---------REMOVED SOME HOSTVAR OUTPUT FOR BREVITY AND PRIVACY--------

TASK [debug] ****************************************************************************************************************************************************************task path: /home/alex/git.sigma/SDG-Tech-DevOps/ansible/301_pb_testing.yml:18
fatal: [demi-win00]: FAILED! =&gt; 
  msg: |-
    The task includes an option with an undefined variable. The error was: 'ansible_local' is undefined
  
    The error appears to be in '/home/alex/git.sigma/SDG-Tech-DevOps/ansible/301_pb_testing.yml': line 18, column 7, but may
    be elsewhere in the file depending on the exact syntax problem.
  
    The offending line appears to be:
  
  
        - debug:
          ^ here

ansible 2.9.12
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/alex/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.9 (default, Jul 17 2020, 12:50:27) [GCC 8.4.0]

The ansible Controller is running debian, The remote is Windows Server 2019
I would expect ansible_local to be populated once setup is run over a valid custom fact, but It doesn't. What am I doing wrong?
According to documentation:

NOTE - For windows clients, the results will be added to a variable
named after the local file (without extension suffix), rather than ansible_local.

According to your example it should be in ansible_foo, but take into consideration that the files in the path must be PowerShell scripts (with extension .ps1) so maybe foo.fact wasn't actually executed.
Hope it helps.