Ansible-无法使变量工作
我正在测试ansible中的变量特性以及include_vars和first_found 我的剧本是Ansible-无法使变量工作,ansible,Ansible,我正在测试ansible中的变量特性以及include_vars和first_found 我的剧本是 --- - name: Load Variables from files. include_vars: "{{ item }}" with_first_found: - "a.yml" - "b.yml" - "default.yml" - name: another play hosts: all tasks: - debug: msg="h
---
- name: Load Variables from files.
include_vars: "{{ item }}"
with_first_found:
- "a.yml"
- "b.yml"
- "default.yml"
- name: another play
hosts: all
tasks:
- debug: msg="hello {{ http_port }}"
但是当我运行这个时,我得到了错误
# ansible-playbook -i inventory/plat-inventory test.yaml
ERROR! 'with_first_found' is not a valid attribute for a Play
The error appears to have been in '/root/config-3.0.98/ansible/test.yaml': line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
---
- name: Load Variables from files.
^ here
default.yml声明:
http_port: 80
我错过了什么 据我所知,包含变量应该是一项任务,如中的示例所示
差不多
- name: playbook
hosts: somehosts
gather_facts: false
tasks:
- name: "add some vars"
include_vars: somefile.yml
但是,这些变量可能不会出现在其他剧本中