我使用Ansible的shell模塊來查找特定字符串並將其存儲在變量中。但是,如果grep沒有找到任何東西,我得到一個錯誤。當grep結果爲空時,Ansible shell模塊返回錯誤
例子:
- name: Get the http_status
shell: grep "http_status=" /var/httpd.txt
register: cmdln
check_mode: no
當我運行此Ansible劇本,如果http_status
字符串是不存在的,劇本被停止。我沒有看到stderr。
即使找不到字符串,我如何使Ansible運行而不會中斷?
我的問題,如果空還我想運行,而不爲,包括一些真正通過failed_when失效條件檢測interption – SSN