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.
Just an FYI there may be a bug with fact_path that I’ve opened https://github.com/ansible-collections/ansible.windows/issues/106. I’m not sure if this bug can be easily fixed so stay tuned to that. Another option if you have custom facts is to create your own fact module. They are quite simple to do as well.
A further FYI, do not include the | ConvertTo-Json part, just output the hashtable or array directory, the issue has been updated with more information as to why that is.
The behaviour of the fact names is hard coded, it cannot change without breaking others who use ‘fact_path’ on Windows. If you desire a custom fact layout then you should create your own fact PowerShell module and run that.