Just try it out and see for yourself. I have placed the following script at 
C:\Windows\TEMP\facts\my_facts.ps1 with the contents

@{
    my_custom_fact = 'value'
    my_complex_custom_fact = @{
        hello = 'world'
    }
} | ConvertTo-Json -Compress

This script converts a PowerShell hashtable (like a dictionary) to a JSON 
and outputs it for the setup module to collect.

Then run 'ansible windows -m setup -a fact_path=C:/Windows/TEMP/facts' and 
look at the output.



On Thursday, September 17, 2020 at 4:35:37 PM UTC+10 [email protected] wrote:

> Can anyone point me in the direction of how to setup custom/local facts on 
> Windows please? not just use fact_path...
>
> Reading the docs I've found so far, it looks like you can't just have a 
> file with key:value like Linux under the heading [local_facts] for example 
> (unless you can? but setup doesn't pick up the values when i run ansible 
> setup against the windows host). The docs/google suggest you need to add 
> .ps1 scripts to a directory (fact_path DIR) and then get JSON output of the 
> facts you want to know about.
>
> That sounds ok as it's similar to creating a dynamic inventory, but can 
> anyone share what the output looks like? Better yet, if anyone knows where 
> a document is that explains this process that would be great.
>
> Thanks for your help!
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/93fee2ca-4702-4b24-95d9-3a25bb715421n%40googlegroups.com.

Reply via email to