![Ansible 不支持(预期)模块错误参数?](https://linux22.com/image/738154/Ansible%20%E4%B8%8D%E6%94%AF%E6%8C%81%EF%BC%88%E9%A2%84%E6%9C%9F%EF%BC%89%E6%A8%A1%E5%9D%97%E9%94%99%E8%AF%AF%E5%8F%82%E6%95%B0%EF%BC%9F.png)
我正在编写一个用于自动安装 anaconda 的剧本。我正在使用 Ansible expect 模块来回答安装提示。这是我的代码。
---
- hosts: all
become: yes
become_method: sudo
gather_facts: true
tasks:
- name: Run the installer Anaconda
expect:
command: bash ~/Downloads/Anaconda3-2019.03-Linux-x86_64.sh
responses:
"Please, press ENTER to continue" : "\n"
"More" : " "
" Do you accept the license terms" : "yes"
"Press ENTER to confirm the location" : "\n"
"Do you wish the installer to initialize Anaconda3 by running conda init": "yes"
这是我得到的错误。任务 [运行安装程序 Anaconda] ***************************************************
致命:[192.168.6.230]:失败! => {“changed”:false,“msg”:“(expect)模块不支持的参数:您是否接受许可条款,您是否希望安装程序通过运行 conda init 来初始化 Anaconda3,更多,请按 ENTER 继续,按 ENTER 确认位置支持的参数包括:chdir、command、creates、echo、removes、response、timeout”}
答案1
您需要缩进您的回复:
responses:
- "Please, press ENTER to continue" : "\n"
- "More" : " "
- " Do you accept the license terms" : "yes"
- "Press ENTER to confirm the location" : "\n"
- "Do you wish the installer to initialize Anaconda3 by running conda init": "yes"
否则,它们仅被视为该expect
部分的下一个参数。YAML 严重依赖于正确的缩进。