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*


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


--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1c5d6e77-0a5c-f2ad-14d2-ebe7b57f2290%40ansible.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to