ERROR! conflicting action statements (expect, command) in Ansible -
i'm trying install java on several hosts ansible. looked examples of expect
module provide answers prompts. think syntax quite fine:
- hosts: datanode sudo: yes sudo_user: root tasks: - expect: name: install java jdk 7 command: apt-get install openjdk-7-jdk responses: question: 'do want continue? [y/n]': 'y'
but when try execute ansible-playbook file.yml
receive error:
error! conflicting action statements (expect, command) error appears have been in '/root/scp.yml': line 5, column 5, may elsewhere in file depending on exact syntax problem. offending line appears be: tasks: - expect: ^ here
where problem? (i have installed ansible 2.0.1.0, pexpect, python)
thanks!
note ansible works yaml files, , kind of files indented. means spaces put before each statement important let ansible understand how nested. more info yaml.
corrected task:
- hosts: datanode sudo: yes sudo_user: root tasks: - name: install java jdk 7 expect: command: apt-get install openjdk-7-jdk responses: question: - 'y' - 'n'
this avoid syntax error.
source: http://docs.ansible.com/ansible/expect_module.html
alternatively, if want "yes" apt-get install
commands, can add -y
argument:
apt-get install -y openjdk-7-jdk
or better, use apt
ansible module.
Comments
Post a Comment