shell - 如何从 Ansible 的 Shell 脚本中搜索寄存器变量中的单词?
问题描述
我对 ansible 很陌生,我正在编写一组代码,其中 shell 命令的结果转到 Register 变量,在该变量中,我需要找到关键字“happy”。如果找到关键字,则执行另一个 shell 脚本。Shell 命令显然输出多个不同的值,看起来像一个字典,它不是一个直截了当的字符串,所以我如何在整个 shell 结果中找到一个单词。
我的尝试:
- name: execute first task
shell: /tmp/somescript
register: myResult
- name: another shell script
shell: /tmp/anotherscript
when: "happy" in myResult.
当输出对每个输出结果感到满意时,这将返回“条件为假”。
解决方案
推荐阅读
- javascript - 我们的第三方 javascript 依赖项导出了一个 50KB 的默认对象,如何让 webpack 只在包中包含部分对象?
- c++ - 如何在另一个类中初始化将字符串作为输入的类对象
- python - 从站忽略的广播消息
- python-3.x - 从字典列表中获取最大值的键
- javascript - 具有类继承的私有字段访问
- python - 没有名为“sklearn.externals.joblib”的模块错误
- mitmproxy - 在运行 MITM 代理的透明模式下,很少有 HTTPS 请求无法捕获
- r - 在 R Shiny 中创建第二个 UI 元素
- sql - 将包含过滤器的 IBM Cognos SQL 转换为 Microsoft SQL Server Query
- typescript - 无法导入与 WebPack 捆绑的 TypeScript 库