早上接到同事反馈说Grafana某个监控图表点击后反应很慢,其他的图表都正常,只有这一张图表很慢。经过和大数据部门同事的沟通,发现应该是从大数据系统推送出来的数据有点问题,需要联合Grafana机器进行调试,询问我Grafana部署在哪台机器上。
由于公司不同区域都有一套Prometheus+Grafana,我也并不记得具体在那台机器上,所以我决定用Ansible批量查询Grafana进程。
但在执行时出现以下错误:
[root@vm09 ~]# ansible -m shell -a "ps -ef|grep 'grafana'" all [WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details [WARNING]: * Failed to parse /etc/ansible/hosts with yaml plugin: We were unable to read either as JSON nor YAML, these are the errors we got from each: JSON: No JSON object could be decoded Syntax Error while loading YAML. did not find expected <document start> The error appears to be in '/etc/ansible/hosts': line 2, column 1, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: [app] app01 ^ here [WARNING]: * Failed to parse /etc/ansible/hosts with constructed plugin: We were unable to read either as JSON nor YAML, these are the errors we got from each: JSON: No JSON object could be decoded Syntax Error while loading YAML. did not find expected <document start> The error appears to be in '/etc/ansible/hosts': line 2, column 1, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: [app] app01 ^ here [WARNING]: * Failed to parse /etc/ansible/hosts with ini plugin: host range must be begin:end or begin:end:step [WARNING]: Unable to parse /etc/ansible/hosts as an inventory source [WARNING]: No inventory was parsed, only implicit localhost is available [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
通过以下命令查询也是0个机器。
ansible all --list-hosts
但是ansible -m shell -a "ps -ef|grep 'grafana'" 某组名
是可以执行的,这就让我很奇怪。
经过一个小时左右的排查,发现有人将/etc/ansible/hosts修改错误。
原因
应该是分号切割,不知道是谁修改错了 导致all无法使用。
将 'ydy-gz[01-35]' 改为 'ydy-gz[01:35]' 即可恢复正常。
标签:plugin,ansible,parse,etc,JSON,WARNING,报错,hosts
From: https://www.cnblogs.com/liushiya/p/18069919