All Ansible playbook attributes

梦想的初衷 提交于 2019-12-12 13:13:26

问题


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.


回答1:


You can always look into the code:

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

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

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

Update:

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();'


来源:https://stackoverflow.com/questions/41228683/all-ansible-playbook-attributes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!