What are Ansible module attributes?

741 Views Asked by At

Each Ansible module's documentation page has an "Attributes" section.

For example, here is the one for the command module. It has these attributes: check_mode, diff_mode, platform and raw.

In general, how do I use a module's attributes?

And in this particular example, what is the platform attribute and how do I use it?

1

There are 1 best solutions below

0
U880D On BEST ANSWER

What are Ansible module attributes?

These are documentation only. They describe some of the capabilities and properties of the module.

I know for example that check_mode and diff_mode correspond to CLI switches.

They mean only that the module which was developed has implemented the capabilities to use check_mode or diff_mode. In other words, they state only if check_mode or diff_mode "are supported" by the module and if you can take advantage of Using check mode or Using diff mode.

So I assume that I can "use" the platform attribute as well,

No, as it states only for which target platform the module was developed. An attribure platform: posix means you can't use the module on Windows.

Some background information can be found within the Developer Guide of the Ansible documentation.


I'd like to know whether I can ... run a task that only targets certain OSs.

For such Use Case it is recommended to use Ansible facts and Conditionals based on ansible_facts, specifically os_family.

Some References

for Windows targets ...