title: ansible- expect module with cisco ios switch
body: <p>If I try to use expect module in YAML file like this:</p>
  
  <pre><code>   name: some tests
        hosts: sw-test
        gather_facts: False
  
        tasks:
        - name: do reload in case of "catting off"
          expect:
           command: reload in 30
           responses:
            'Reload scheduled in 30 minutes by admin on vty0 (192.168.253.20)\nProceed with reload? \[confirm\]' : y
           echo: yes
  </code></pre>
  
  <p>But there is a problem with connection:</p>
  
  <pre><code>root@Kali:/etc/ansible# ansible-playbook test3 -u admin -k -vvvv 
  Using /etc/ansible/ansible.cfg as config file
  SSH password: 
  Loaded callback default of type stdout, v2.0
  
  PLAYBOOK: test3 ****************************************************************
  1 plays in test3
  
  PLAY [some tests] **************************************************************
  
  TASK [do reload in case of "catting off"] **************************************
  task path: /etc/ansible/test3:9
  &lt;192.168.0.33&gt; ESTABLISH SSH CONNECTION FOR USER: admin
  &lt;192.168.0.33&gt; SSH: EXEC sshpass -d12 ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=admin -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r 192.168.0.33 '/bin/sh -c '"'"'( umask 77 &amp;&amp; mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1476882070.37-92402455055985 `" &amp;&amp; echo ansible-tmp-1476882070.37-92402455055985="` echo $HOME/.ansible/tmp/ansible-tmp-1476882070.37-92402455055985 `" ) &amp;&amp; sleep 0'"'"''
  &lt;192.168.0.33&gt; PUT /tmp/tmp30wGsF TO "` echo $HOME/.ansible/tmp/ansible-tmp-1476882070.37-92402455055985 `" ) &amp;&amp; sleep 0'"/expect
  &lt;192.168.0.33&gt; SSH: EXEC sshpass -d12 sftp -o BatchMode=no -b - -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=admin -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r '[192.168.0.33]'
  fatal: [192.168.0.33]: UNREACHABLE! =&gt; {"changed": false, "msg": "SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh", "unreachable": true}
      to retry, use: --limit @/etc/ansible/test3.retry
  
  PLAY RECAP *********************************************************************
  192.168.0.33               : ok=0    changed=0    unreachable=1    failed=0   
  
  
  root@Kali:/etc/ansible# ansible-playbook test3 -u admin -k -vvvv -c ssh
  Using /etc/ansible/ansible.cfg as config file
  SSH password: 
  Loaded callback default of type stdout, v2.0
  
  PLAYBOOK: test3 ****************************************************************
  1 plays in test3
  
  PLAY [some tests] **************************************************************
  
  TASK [do reload in case of "catting off"] **************************************
  task path: /etc/ansible/test3:9
  &lt;192.168.0.33&gt; ESTABLISH SSH CONNECTION FOR USER: admin
  &lt;192.168.0.33&gt; SSH: EXEC sshpass -d12 ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=admin -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r 192.168.0.33 '/bin/sh -c '"'"'( umask 77 &amp;&amp; mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1476882145.78-139203779538157 `" &amp;&amp; echo ansible-tmp-1476882145.78-139203779538157="` echo $HOME/.ansible/tmp/ansible-tmp-1476882145.78-139203779538157 `" ) &amp;&amp; sleep 0'"'"''
  &lt;192.168.0.33&gt; PUT /tmp/tmpY5qqyW TO "` echo $HOME/.ansible/tmp/ansible-tmp-1476882145.78-139203779538157 `" ) &amp;&amp; sleep 0'"/expect
  &lt;192.168.0.33&gt; SSH: EXEC sshpass -d12 sftp -o BatchMode=no -b - -C -vvv -o 
  
  ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=admin -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r '[192.168.0.33]'
      fatal: [192.168.0.33]: UNREACHABLE! =&gt; {"changed": false, "msg": "SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh", "unreachable": true}
          to retry, use: --limit @/etc/ansible/test3.retry
  
      PLAY RECAP *********************************************************************
      192.168.0.33               : ok=0    changed=0    unreachable=1    failed=0   
  
  root@Kali:/etc/ansible# ansible-playbook test3 -u admin -k -vvvv -c local
  Using /etc/ansible/ansible.cfg as config file
  SSH password: 
  Loaded callback default of type stdout, v2.0
  
  PLAYBOOK: test3 ****************************************************************
  1 plays in test3
  
  PLAY [some tests] **************************************************************
  
  TASK [do reload in case of "catting off"] **************************************
  task path: /etc/ansible/test3:9
  &lt;192.168.0.33&gt; ESTABLISH LOCAL CONNECTION FOR USER: root
  &lt;192.168.0.33&gt; EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1476882426.62-172601217553809 `" &amp;&amp; echo ansible-tmp-1476882426.62-172601217553809="` echo $HOME/.ansible/tmp/ansible-tmp-1476882426.62-172601217553809 `" ) &amp;&amp; sleep 0'
  &lt;192.168.0.33&gt; PUT /tmp/tmpdq1pYy TO /root/.ansible/tmp/ansible-tmp-1476882426.62-172601217553809/expect
  &lt;192.168.0.33&gt; EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1476882426.62-172601217553809/ /root/.ansible/tmp/ansible-tmp-1476882426.62-172601217553809/expect &amp;&amp; sleep 0'
  &lt;192.168.0.33&gt; EXEC /bin/sh -c 'LANG=pl_PL.UTF-8 LC_ALL=pl_PL.UTF-8 LC_MESSAGES=pl_PL.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1476882426.62-172601217553809/expect; rm -rf "/root/.ansible/tmp/ansible-tmp-1476882426.62-172601217553809/" &gt; /dev/null 2&gt;&amp;1 &amp;&amp; sleep 0'
  fatal: [192.168.0.33]: FAILED! =&gt; {"changed": false, "failed": true, "invocation": {"module_args": {"chdir": null, "command": "reload in 30", "creates": null, "echo": true, "removes": null, "responses": {"Reload scheduled in 30 minutes by admin on vty0 (192.168.253.20)\\nProceed with reload? \\[confirm\\]": "y"}, "timeout": 30}, "module_name": "expect"}, "msg": "The command was not found or was not executable: reload."}
  
  NO MORE HOSTS LEFT *************************************************************
      to retry, use: --limit @/etc/ansible/test3.retry
  
  PLAY RECAP *********************************************************************
  192.168.0.33               : ok=0    changed=0    unreachable=0    failed=1   
  </code></pre>
  
  <p>Is it possible to use expect module with cisco ios switch?
  I have no such problem when I use for instance "ios_command" module.</p>