所以我是Ansible的新手,但我一直在研究,而且我找不到任何可以解釋此問題的文章。我創建了一個安裝Brew桶應用程序的角色,但是它在運行命令以檢查應用程序是否已安裝時保持'失敗'。Ansible任務失敗,即使使用ignore_errors
這裏的任務:
- name: "Check for installed casks (Applications)"
shell: brew cask list | grep {{ item }}
register: installed_applications
with_items: "{{ apps }}"
when: apps is defined
ignore_errors: yes
所以,從我個人理解,它將運行從我的應用程序列表中的項目的命令,這樣的例子命令是brew cask list | grep keybase
,然後映射,爲installed_applications
。
但是,當我運行它,我最終看到所有的應用程序失敗(沒有安裝)。下面是詳細模式錯誤:
failed: [localhost] (item=keybase) => {
"changed": true,
"cmd": "brew cask list | grep keybase",
"delta": "0:00:00.792680",
"end": "2017-03-03 19:41:05.500378",
"failed": true,
"invocation": {
"module_args": {
"_raw_params": "brew cask list | grep keybase",
"_uses_shell": true,
"chdir": null,
"creates": null,
"executable": null,
"removes": null,
"warn": false
},
"module_name": "command"
},
"item": "keybase",
"rc": 1,
"start": "2017-03-03 19:41:04.707698",
"stderr": "",
"stdout": "",
"stdout_lines": [],
"warnings": []
}
如果我手動運行該命令,我只是得到了一個空白輸出(因爲它應該),但Ansible應該忽略的錯誤,對吧?
阿爾,這很好的知道。謝謝! –