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

Consider e.g. ansible.builtin.stat vs ansible.windows.win_stat.

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?

1 Like

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

Argh, but the galaxy.yml doesn’t have a field for OS support.

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.

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.

1 Like