如何读取文件变量以创建角色的全局条形图



如何从启动的剧本加载hosts.yml文件,以及在角色中使用值。

我推出:

$ ansible-playbook proxy_squid.yml -i ./group_vars/hosts.yml -vvvvv

但我收到:

ansible-playbook 2.5.1
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/user/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible-playbook
python version = 2.7.17 (default, Jul 20 2020, 15:37:01) [GCC 7.5.0]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
Parsed /home/user/repo/Iso27001/ansible/group_vars/hosts.yml inventory source with yaml plugin
Read vars_file './group_vars/vault_data.yml'
Read vars_file './group_vars/vault_ip.yml'
Read vars_file './group_vars/hosts.yml'
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/dist-packages/ansible/plugins/callback/default.pyc
PLAYBOOK: proxy_squid.yml *****************************************************************
1 plays in proxy_squid.yml
Read vars_file './group_vars/vault_data.yml'
Read vars_file './group_vars/vault_ip.yml'
Read vars_file './group_vars/hosts.yml'
ERROR! The field 'hosts' has an invalid value, which includes an undefined variable. The error was: 'h_tmpvm' is undefined
The error appears to have been in '/home/user/repo/ansible/proxy_squid.yml': line 3, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
---
- name: Declaring conf
^ here

非常感谢!!

我发现。。。目标主机中未安装python。很抱歉