所有 Ansible 剧本属性 [英] All Ansible playbook attributes

查看:23
本文介绍了所有 Ansible 剧本属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用 Ansible,在阅读了教程(Ansible 团队将其命名为 docs")后,我想查看可在剧本中使用的所有属性的完整列表.有人能够提供这样的清单吗?我唯一能用谷歌搜索的是这个老例子,但它缺少gather_facts.

也许有经验的人可以在这里粘贴一个包含所有属性的正确结构的骨架".

提前致谢.

I've just started using Ansible, and after reading the tutorial (which Ansible Team named "docs") I would like to see the full list of all attributes which can be used in playbooks. Is someone able to provide such a list? The only one I was able to Google was this old example but it lack the things like gather_facts.

Maybe someone experienced could paste here a 'skeleton' with the correct structure containing all the atributes.

Thanks in advance.

推荐答案

您可以随时查看 代码:

# =================================================================================
# Connection-Related Attributes

# TODO: generalize connection
_accelerate          = FieldAttribute(isa='bool', default=False, always_post_validate=True)
_accelerate_ipv6     = FieldAttribute(isa='bool', default=False, always_post_validate=True)
_accelerate_port     = FieldAttribute(isa='int', default=5099, always_post_validate=True)

# Connection
_gather_facts        = FieldAttribute(isa='bool', default=None, always_post_validate=True)
_gather_subset       = FieldAttribute(isa='barelist', default=None, always_post_validate=True)
_gather_timeout      = FieldAttribute(isa='int', default=None, always_post_validate=True)
_hosts               = FieldAttribute(isa='list', required=True, listof=string_types, always_post_validate=True)
_name                = FieldAttribute(isa='string', default='', always_post_validate=True)

# Variable Attributes
_vars_files          = FieldAttribute(isa='list', default=[], priority=99)
_vars_prompt         = FieldAttribute(isa='list', default=[], always_post_validate=True)
_vault_password      = FieldAttribute(isa='string', always_post_validate=True)

# Role Attributes
_roles               = FieldAttribute(isa='list', default=[], priority=90)

# Block (Task) Lists Attributes
_handlers            = FieldAttribute(isa='list', default=[])
_pre_tasks           = FieldAttribute(isa='list', default=[])
_post_tasks          = FieldAttribute(isa='list', default=[])
_tasks               = FieldAttribute(isa='list', default=[])

# Flag/Setting Attributes
_any_errors_fatal    = FieldAttribute(isa='bool', default=False, always_post_validate=True)
_force_handlers      = FieldAttribute(isa='bool', always_post_validate=True)
_max_fail_percentage = FieldAttribute(isa='percent', always_post_validate=True)
_serial              = FieldAttribute(isa='list', default=[], always_post_validate=True)
_strategy            = FieldAttribute(isa='string', default=C.DEFAULT_STRATEGY, always_post_validate=True)

# =================================================================================

另请注意,Play 类继承了 BaseTaggableBecome.
因此,所有这些类的属性也可用于播放.

Also note that Play class inherits Base, Taggable and Become.
So all those classes' attributes are also available to plays.

更新:

这是我在另一个问题中建议的 Python oneliner:

Here is a Python oneliner suggested by me in another question:

python -c 'import ansible.playbook.play as P; print P.Play()._valid_attrs.keys();'

这篇关于所有 Ansible 剧本属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆