英文:
What are Ansible module attributes?
问题
每个Ansible模块的文档页面都有一个“Attributes”(属性)部分。例如,这里是command
模块的文档页面。它具有以下属性:check_mode
,diff_mode
,platform
和raw
。
通常情况下,我如何使用模块的属性?
在这个特定示例中,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_mode
和diff_mode
对应于 CLI 开关。它们只意味着开发的模块已实现了使用
check_mode
或diff_mode
的功能。换句话说,它们仅说明模块是否支持check_mode
或diff_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 ...
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论