pythonansiblepexpectpxssh

Can the Ansible raw ssh module be used like "expect"?


In other words, can the ansible "expect" module be used over a raw SSH connection?

I'm trying automate some simple embedded devices that do not have a full Python or even shell. The ansible raw module works fine for simple commands, but I'd like to drive things in an expect-like manner.

Can this be done?


Solution

  • The expect module is written in python, so no, that won't work.

    Ansible does have a model for interacting with devices like network switches that similarly don't run python; you can read about that in the How Network Automation Is Different. I don't think that will offer any sort of immediate solution to your problem, but it suggests a way of pursuing things if it was really important to integrate with Ansible.

    It would probably be simpler to just use the actual expect program instead of Ansible.