感谢我提供给Demo的回复,我了解了Expect模块。在我的Ansible playbook中,我使用它来执行命令并响应提示。我现在的问题是我的command
在提示用户名,电子邮件和密码之前返回stdout警告文本。然后,期望任务失败,我猜是因为它现在不知道如何处理这行文本。
我的 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: "]}
不幸的是,我无法在配置的这个阶段禁用警告。
感谢您提供任何帮助。
答案 0 :(得分:1)
响应搜索词组区分大小写! 使用:
responses:
(?i)username: test
或:
SNMPv3