I am playing around with Ansible on Ubuntu 14.04 VMs and can’t seem to get expect to work. I have tried installing ansible and pexpect via apt-get and pip, but keep getting the following error:
fatal: [vagrant]: FAILED! => {“changed”: false, “failed”: true, “invocation”: {“module_args”: {“chdir”: null, “command”: “domainjoin-cli leave user”, “creates”: null, “echo”: false, “removes”: null, “responses”: {“password”: “password”}, “timeout”: 30}, “module_name”: “expect”}, “msg”: “The pexpect python module is required”}
“pip freeze” says:
Jinja2==2.8
Landscape-Client==14.12
MarkupSafe==0.23
PAM==0.4.2
PyYAML==3.11
Twisted-Core==13.2.0
ansible==2.0.0.2
apt-xapian-index==0.45
argparse==1.2.1
chardet==2.0.1
colorama==0.2.5
configobj==4.7.2
ecdsa==0.13
html5lib==0.999
paramiko==1.16.0
pexpect==4.0.1
ptyprocess==0.5
pyOpenSSL==0.13
pycrypto==2.6.1
pyserial==2.6
python-apt==0.9.3.5ubuntu2
python-debian==0.1.21-nmu2ubuntu2
requests==2.2.1
six==1.5.2
ssh-import-id==3.21
urllib3==1.7.1
wheel==0.24.0
wsgiref==0.1.2
zope.interface==4.0.5
my playbook code:
- hosts: local_lab
remote_user: vagrant
become: true
vars:
admin_user: “{{user}}”
admin_pass: “{{pass}}”
tasks:- name: pbis-open - remove old - leave domain
expect:
command: domainjoin-cli leave {{admin_user}}
responses:
(?i)password: “{{admin_pass}}”
my cli command:
ansible-playbook -vvvv pbis-open.yml --inventory-file=lab --extra-vars=“user=user pass=password”
Thanks for your time. Any help is greatly appreciated.