所以我是 Ansible 的新手,但我一直在研究,我找不到任何可以解释这个问题的文章。我创建了一个角色来安装 brew cask 应用程序,但它在运行命令以检查应用程序是否已安装时一直“失败”。
这是任务:
- 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 应该忽略错误,对吗?