Ansible 2.2 ios modules are failing with message "Failed to connect to the host via ssh."

274 views
Skip to first unread message

davis mathew kuriakose

unread,
May 25, 2016, 10:22:03 AM5/25/16
to Ansible Project, davis.k...@emcconnected.com
I'm not able to run ios_command module in Ansible 2.1 for executing commands on my cisco routers.


I've written a playbook for testing ios_command module on cisco routers.

Following is the playbook I wrote 


---
 
- hosts: router2

   tasks:

     - ios_command:

        username: cisco

        password: cisco

#         host: router2.3node.example.com

        commands:

          - show version

        register: output

     - debug: msg="Hello World! {{ output.stdout }}"


But the playbook fails with the following message :


fatal: [router2.3node.example.com]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": true}


and value unreachable=1


Also find the output while run on debug mode




TASK [setup] *******************************************************************

Using module file /home/cisco/ansible_dev/ansible/lib/ansible/modules/core/system/setup.py

<router2.3node.example.com> ESTABLISH SSH CONNECTION FOR USER: None

<router2.3node.example.com> SSH: EXEC ssh -C -q -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/cisco/.ansible/cp/ansible-ssh-%h-%p-%r router2.3node.example.com '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1464109982.9-18150317646623 `" && echo ansible-tmp-1464109982.9-18150317646623="` echo $HOME/.ansible/tmp/ansible-tmp-1464109982.9-18150317646623 `" ) && sleep 0'"'"''



fatal: [router2.3node.example.com]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": true}


Please let me know if someone has tried the same and solved this problem.

Thanks & Regards,
Davis

Peter Sprygada

unread,
May 25, 2016, 11:22:20 AM5/25/16
to ansible...@googlegroups.com
Add connection: local to your playbook

On 5/24/16 1:19 PM, davis mathew kuriakose wrote:
> I'm not able to run ios_command module in Ansible 2.1 for executing
> commands on my cisco routers.
>
>
> I've written a playbook for testing ios_command module on cisco routers.
>
> Following is the playbook I wrote
>
>
> ---
> - hosts: router2
>
> tasks:
>
> - ios_command:
>
> username: cisco
>
> password: cisco
>
> # host: router2.3node.example.com
>
> commands:
>
> - show version
>
> register: output
>
> - debug: msg="Hello World! {{ output.stdout }}"
>
>
> But the playbook fails with the following message :
>
>
> *fatal: [router2.3node.example.com]: UNREACHABLE! => {"changed": false,
> "msg": "Failed to connect to the host via ssh.", "unreachable": true}*
>
>
> and value *unreachable=1*
Reply all
Reply to author
Forward
0 new messages