Ansible模块属性是什么?

huangapple go评论58阅读模式
英文:

What are Ansible module attributes?

问题

每个Ansible模块的文档页面都有一个“Attributes”(属性)部分。例如,这里command模块的文档页面。它具有以下属性:check_modediff_modeplatformraw

通常情况下,我如何使用模块的属性?

在这个特定示例中,platform属性是什么,我如何使用它?

英文:

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

得分: 1

以下是您要翻译的内容:

什么是 Ansible 模块属性?

这些只是文档。它们描述了模块的一些功能和属性。

我知道例如 check_modediff_mode 对应于 CLI 开关。

它们只意味着开发的模块已实现了使用 check_modediff_mode 的功能。换句话说,它们仅说明模块是否支持 check_modediff_mode,以及您是否可以利用使用检查模式使用差异模式

所以我认为我也可以“使用” platform 属性,

不可以,因为它只说明模块是为哪个目标平台开发的。属性 platform: posix 意味着您不能在 Windows 上使用该模块。

一些背景信息可以在 Ansible 文档的开发者指南中找到。


我想知道是否可以...运行只针对特定操作系统的任务。

对于这种用例,建议使用Ansible 事实和基于 ansible_facts条件语句,特别是 os_family

一些参考资料

对于 Windows 目标...

英文:

> 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 ...

huangapple
  • 本文由 发表于 2023年5月17日 12:50:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/76268652.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定