忽略期望范围内的错误

时间:2019-10-10 11:39:34

标签: ansible

我正在进行构建,默认情况下会返回“构建失败”。这是所需的输出,但会中断剧本的执行。

我尝试在命令后添加ignore_errors,但由于它不是期望的有效参数,因此我不允许这样做。

- name: Do a build.
  expect:
    command: build
    responses:
      'Password\:': ''

我希望它在要求输入密码时通过密码,忽略出现的构建失败消息,然后继续其余步骤。有人可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

ignore_errors is a task parameter,而不是expect模块参数。只是从您的问题中得出的一个猜测:您没有使用正确的缩进。

以下错误

# Will error with unknown parameter for module expect
- name: Do a build.
  expect:
    command: build
    responses:
      'Password\:': ''
    ignore_errors: true

这应该有效:

- name: Do a build.
  expect:
    command: build
    responses:
      'Password\:': ''
  ignore_errors: true

不要忘记yaml中的空格和缩进很重要。花几分钟时间查看fast reading lighten spec