相关疑难解决方法(0)

当grep结果为空时,Ansible shell模块返回错误

我正在使用Ansible的shell模块来查找特定字符串并将其存储在变量中.但如果grep没有找到任何东西我会收到错误.

例:

- name: Get the http_status
  shell: grep "http_status=" /var/httpd.txt
  register: cmdln
  check_mode: no
Run Code Online (Sandbox Code Playgroud)

当我运行这个Ansible playbook时,如果http_status没有字符串,则停止播放.我没有得到stderr.

即使找不到字符串,如何在不中断的情况下运行Ansible?

grep ansible

22
推荐指数
2
解决办法
2万
查看次数

标签 统计

ansible ×1

grep ×1