首页 > 其他分享 >Ansible报错:Failed to parse /etc/ansible/hosts with yaml plugin

Ansible报错:Failed to parse /etc/ansible/hosts with yaml plugin

时间:2024-03-13 09:44:38浏览次数:21  
标签:plugin ansible parse etc JSON WARNING 报错 hosts

早上接到同事反馈说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

相关文章

  • LeetCode每日一题[C++]-2864.最大二进制奇数(贪心)
    题目描述给你一个 二进制 字符串 s ,其中至少包含一个 '1' 。你必须按某种方式 重新排列 字符串中的位,使得到的二进制数字是可以由该组合生成的 最大二进制奇数 。以字符串形式,表示并返回可以由给定组合生成的最大二进制奇数。注意 返回的结果字符串 可以 含前......
  • LeetCode题练习与总结:最长有效括号
    一、题目给你一个只包含'(' 和')' 的字符串,找出最长有效(格式正确且连续)括号子串的长度。二、解题思路1.初始化一个栈和一个变量maxLen来记录最长有效括号子串的长度。栈用于存储左括号的索引,maxLen初始化为0。2.遍历字符串s中的每个字符。对于每个字符,执行以下......
  • [LeetCode][LCR174] 寻找二叉搜索树中的目标节点
    题目LCR174.寻找二叉搜索树中的目标节点某公司组织架构以二叉搜索树形式记录,节点值为处于该职位的员工编号。请返回第cnt大的员工编号。示例1:输入:root=[7,3,9,1,5],cnt=27/\39/\15输出:7示例2:输......
  • 关于树莓派5(Ubnutu 23.10和树莓派5自带的系统通用)下载时出现error: externally-manage
    一.报错产生的原因  最近作者更新了这两个系统,在作者想去安装非 Debian的库的时候总是出现以下的报错:error:externally-managed-environment这是因为树莓派5升级了服务器系统,从Debian11到了Debian12,这个服务器系统对于外接库的限制还是比较严格的。作者也按照系......
  • 代码随想录算法训练营day21 | leetcode 530. 二叉搜索树的最小绝对差、501. 二叉搜索
    目录题目链接:530.二叉搜索树的最小绝对差-简单题目链接:501.二叉搜索树中的众数-简单题目链接:236.二叉树的最近公共祖先-中等题目链接:530.二叉搜索树的最小绝对差-简单题目描述:给你一个二叉搜索树的根节点root,返回树中任意两不同节点值之间的最小差值。差值是一个正数,......
  • LeetCode[题解] 1261. 在受污染的二叉树中查找元素
    首先我们看原题给出一个满足下述规则的二叉树:root.val==0如果 treeNode.val==x 且 treeNode.left!=null,那么 treeNode.left.val==2*x+1如果 treeNode.val==x 且 treeNode.right!=null,那么 treeNode.right.val==2*x+2现在这个二叉树受到「污......
  • hadoop报错:is running 446528000B beyond the 'VIRTUAL' memory limit
    发现问题今天在配置hadoop文件时,报错:isrunning446528000Bbeyondthe'VIRTUAL'memorylimit.Currentusage:73.9MBof1GBphysicalmemoryused;2.5GBof2.1GBvirtualmemoryused.Killingcontainer.意思是虚拟内存,超出了限制。然后将虚拟机内存改为3G关闭集群......
  • 解决安装vue-cli报错
    解决安装vue-cli报错:npmERR!requesttohttps://registry.npm.taobao.org/@vue%2Fclifailed,reason:certificatehasexpired报错显示:报错原因:淘宝镜像地址(npm.taobao.org)SSL证书在2024年1月22日过期,现已经更换为npmmirror.com解决方法:以管理员身份打开命令提示......
  • 2024-03-12 leetcode写题记录
    目录2024-03-12leetcode写题记录160.相交链表题目链接题意解法解法一解法二2024-03-12leetcode写题记录160.相交链表题目链接160.相交链表题意给你两个单链表的头节点\(headA\)和\(headB\),请你找出并返回两个单链表相交的起始节点。如果两个链表不存在相交节点,返回\(nu......
  • 记录报错内容以及如何修改(mapper包下面的映射文件扫描不到)
    这个错误是在使用mybatis和mapper的时候发生的,一般报这种错误都是因为配置不匹配,或者是写错了路径,或者是写的sql语句有了问题,但是我检查了很多遍都没有发现任何有关语句和路径的错误。 排除了这些低级错误的可能后,这里会报错的原因也基本就只有一个了,那就是mapper接口和mapper.......