ansible - ansible无法识别yq处理器
问题描述
团队,在我的剧本中,我在 shell 模块中调用 yq 但它抱怨路径。有人可以帮忙吗?我已经手动测试过 yq 和 jq 都可用。
cat $HOME/.kube/config/cluster-user.kubeconfig | yq .contexts[0].name```
"site.test.com"
"site.test.com"
- name: "GET API server current-context name with YQ.. "
shell: "cat $HOME/.kube/config/cluster-user.kubeconfig | yq .[\"current-context\"]"
register: string1
ignore_errors: true
- debug:
var: string1.stdout_lines
when: string1.stdout != ''
- name: "GET API server contexts name with YQ.. "
shell: "cat $HOME/.kube/config/cluster-user.kubeconfig | yq .contexts[0].name"
register: string2
ignore_errors: true
- debug:
var: string2.stdout_lines
when: string2.stdout != ''
- fail:
msg: "Validate if both string1 and string2 are same, if yes proceed..."
when: string2.stdout != string1.stdout
任何提示如何使ansible使用二进制文件?
输出:
TASK [GET API server contexts name with YQ..] ******************************************************************************************
fatal: [target1]: FAILED! => {"changed": true, "cmd": "cat $HOME/.kube/config/cluster-user.kubeconfig | yq .contexts[0].name", "delta": "0:00:00.006670", "end": "2019-09-30 18:15:13.829021", "msg": "non-zero return code", "rc": 127, "start": "2019-09-30 18:15:13.822351", "stderr": "/bin/sh: yq: command not found", "stderr_lines": ["/bin/sh: yq: command not found"], "stdout": "", "stdout_lines": []}
...ignoring
解决方案
我所做的是在我的剧本中添加了一个通过 pip 安装 yq 的任务:
- name: Install yq
pip:
name: ['yq']
推荐阅读
- java - Android-WebRTC:设置本地描述后调用 MediaStream.removeVideoTrack
- python - 使用熊猫中的方差范围对列进行分组
- excel - 如何在二维表中使用索引功能
- android - 只获取一次随机数据的数据库查询
- hibernate - 如何解决错误消息:必须与引用的主键具有相同的列数
- xamarin - 如何在 Xamarin 表单中向用户发送用户消息?
- python-3.x - 嗨朋友我刚刚安装了opencv并检查了基本代码,但它导致了错误。代码是:
- r - 如何读取多个变量的最大值并使用 R 中的空间接近值形成平均值?
- jquery - 具有特殊字符和空格的字符串化字符串作为数据属性jquery
- c - 在c中读取名称值对的最佳方法