Ansible(2.9)playbooks使用的是YAML版本1.2。
在Ansible playbook文件的顶部,可以指定YAML版本。以下是一个示例:
---
- name: Example playbook
hosts: all
gather_facts: true
vars:
foo: "bar"
tasks:
- name: Print foo variable
debug:
var: foo
在上面的示例中,"---"表示YAML版本1.2。这是Ansible默认使用的YAML版本,因此通常情况下,您不需要显式指定YAML版本。
如果您想确保使用的是特定的YAML版本,可以在playbook文件中添加"---"来指定版本。