# Better warnings when running a module against the wrong host operating system

**URL:** <https://forum.ansible.com/t/better-warnings-when-running-a-module-against-the-wrong-host-operating-system/44692>\
**Category:** Project Discussions\
**Tags:** windows, ansible-galaxy, ansible-core\
**Created:** [October 15, 2025, 9:36pm UTC](https://forum.ansible.com/t/better-warnings-when-running-a-module-against-the-wrong-host-operating-system/44692 "2025-10-15T21:36:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![davetapley](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/davetapley/32/4291_2.png) [@davetapley](https://forum.ansible.com/u/davetapley)\
**Post date:** [October 15, 2025, 9:36pm UTC](https://forum.ansible.com/t/better-warnings-when-running-a-module-against-the-wrong-host-operating-system/44692/1 "2025-10-15T21:36:24Z")

</div>

Consider e.g. [`ansible.builtin.stat`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/stat_module.htm) vs [`ansible.windows.win_stat`](https://docs.ansible.com/ansible/latest/collections/ansible/windows/win_stat_module.html).

The former will fail with a pretty esoteric error if it’s trying to run on a Windows host.

Presumably `ansible-playbook` has enough information to know that it won’t work?

---

<div class="post-metadata">

**Author:** ![Lyle\_McKarns](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/lyle_mckarns/32/8142_2.png) [@Lyle\_McKarns](https://forum.ansible.com/u/Lyle_McKarns)\
**Post date:** [October 16, 2025, 12:06pm UTC](https://forum.ansible.com/t/better-warnings-when-running-a-module-against-the-wrong-host-operating-system/44692/2 "2025-10-16T12:06:36Z")

</div>

> [@davetapley](#):
>
> Presumably `ansible-playbook` has enough information to know that it won’t work?

If you `gather_facts` (which is `true` by default) then yes, the system is “aware” of which OS a target is running.

---

<div class="post-metadata">

**Author:** ![davetapley](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/davetapley/32/4291_2.png) [@davetapley](https://forum.ansible.com/u/davetapley)\
**Post date:** [October 16, 2025, 8:03pm UTC](https://forum.ansible.com/t/better-warnings-when-running-a-module-against-the-wrong-host-operating-system/44692/3 "2025-10-16T20:03:33Z")

</div>

Argh, but the [`galaxy.yml`](https://docs.ansible.com/ansible/latest/dev_guide/collections_galaxy_meta.html#collections-galaxy-meta) doesn’t have a field for OS support.

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [October 20, 2025, 5:12am UTC](https://forum.ansible.com/t/better-warnings-when-running-a-module-against-the-wrong-host-operating-system/44692/4 "2025-10-20T05:12:07Z")

</div>

There are many problems with trying to do this

- There is no set metadata to say this module works on x platform(s)
- How do you define a platform, macOS, Linux, Unix, Posix, something else?
- How do you guarantee that fact gathering is enabled and this fact has been gathered
- We can’t hardcode extensions to specific platforms as either non-AnsiballZ `.py` modules may work or future support might be enabled for running on different platforms

All in all it’s a difficult problem, the best we can do right now is make sure the documentation reflects what platforms the module can run on.

---

<div class="post-metadata">

**Author:** ![davetapley](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/davetapley/32/4291_2.png) [@davetapley](https://forum.ansible.com/u/davetapley)\
**Post date:** [March 25, 2026, 4:54pm UTC](https://forum.ansible.com/t/better-warnings-when-running-a-module-against-the-wrong-host-operating-system/44692/5 "2026-03-25T16:54:11Z")

</div>

> make sure the documentation reflects what platforms the module can run on.

Yes, but, in the spirit of playbooks, if we could some how make that documentation machine readable, then that would be a good solution to this problem.

I agree it wouldn’t be easy, though.
