在 Ansible Expect 模块中,如何忽略响应提示前显示的警告文本?

In Ansible Expect Module, how to ignore warning text showing before responding to prompts?

感谢 的回复,我了解了 Expect 模块。在我的 Ansible 剧本中,我用它来执行命令和响应提示。我现在的问题是我的 command returns 在提示输入用户名、电子邮件和密码之前输出警告文本。然后 expect 任务失败,我猜是因为它现在不知道如何处理这行文本。

我的playbook.yml

  - expect:
        command: geonode createsuperuser
        responses:
          username: 'test'
          email: 'test@whatever.com'
          password: 'test'

失败报告:

TASK [expect] ******************************************************************
fatal: [node1]: FAILED! => {"changed": true, "cmd": "geonode createsuperuser", "delta": "0:00:30.129827", "end": "2016-07-28 09:39:57.806523", "failed": true, "rc": null, "start": "2016-07-28 09:39:27.676696", "stdout": "Not enabling BingMaps base layer as a BING_API_KEY is not defined in local_settings.py file.\r\nUsername: ", "stdout_lines": ["Not enabling BingMaps base layer as a BING_API_KEY is not defined in local_settings.py file.", "Username: "]}

很遗憾,我无法在配置的这个阶段禁用警告。

感谢您提供的任何帮助。

响应搜索短语区分大小写! 使用:

responses:
  Username: test

或:

responses:
  (?i)username: test