ansible playbook支持的atrributes

有运维或运维开发方面的需求,可以联系博主QQ 452336092或Email:admin#centos.bz(收费)

ansible这个工具的官方文档其实做得特别不好。不仅没有搜索功能,而且对于playbook的各种属性居然没有介绍,特别是gather_facts:这种属性,在特定的场景下关掉是可以减少很多等待时间的。

因为文档上没有,所以基本只能看代码。

# =================================================================================
# 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)

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

还可以通过命令的方式:

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

['tasks', 'vars', 'become_user', 'vault_password', 'gather_subset', 'accelerate', 'diff', 'serial', 'port', 'post_tasks', 'environment', 'remote_user', 'become_method', 'gather_timeout', 'strategy', 'no_log', 'pre_tasks', 'vars_files', 'accelerate_port', 'force_handlers', 'tags', 'gather_facts', 'check_mode', 'always_run', 'run_once', 'max_fail_percentage', 'ignore_errors', 'fact_path', 'name', 'roles', 'handlers', 'any_errors_fatal', 'connection', 'hosts', 'become_flags', 'vars_prompt', 'become', 'accelerate_ipv6', 'order']

原文出处:csdn -> http://blog.csdn.net/u013613428/article/details/78652158

打赏

如果此文对你有所帮助,请随意打赏鼓励作者^_^