Custom facts Windows

Hi,

is it possible to use custom facts on Windows machines, which is the location for storing fact scripts…

Thank you

According to the setup module http://docs.ansible.com/ansible/latest/setup_module.html, you can specify a path to a folder where it will execute custom scripts.

`

  • setup:
    fact_path: C:\temp
    `

With the example above, it will gather the normal facts but will also run each “.ps1” script in C:\temp and add them to the facts. The scripts must output a JSON string which Ansible then adds to the facts returned, this can be done like so

`
$facts = @{}
$facts.ansible_custom_fact = “custom fact”

Write-Output (ConvertTo-Json -InputObject $facts -Compress)
`