我正在尝试使用 Ansible 在多台主机上安装 java。我寻找了一些expect
模块示例来为提示提供答案。我认为这种语法很好:
- hosts: datanode
sudo: yes
sudo_user: root
tasks:
- expect:
name: install java jdk 7
command: apt-get install openjdk-7-jdk
responses:
Question:
'Do you want to continue? [Y/n]': 'Y'
但是当我尝试执行时,ansible-playbook file.yml
我收到错误:
ERROR! conflicting action statements (expect, command)
The error appears to have been in '/root/scp.yml': line 5, column 5, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
tasks:
- expect:
^ here
问题出在哪里?(我已经安装了ansible 2.0.1.0、pexpect、python)
谢谢!