Ansible adhoc command/playbook is not displaying output for the passed argument

315 views
Skip to first unread message

Ajay

unread,
Jun 23, 2018, 10:27:09 PM6/23/18
to Ansible Project
Hi, I am just getting started with ansible and came across this issue. Ansible doesn't print the output of the passed argument to the screen when using raw module for both adhoc command and playbook.

Here is what I see,

[root@localhost ~]$ ansible s1 -m raw -a 'show ip interface brief' -k

SSH password: 
s1 | SUCCESS | rc=0 >>
Shared connection to switch closed.


NO OUTPUT is displayed for the "show ip interface brief" argument



[root@localhost ~]$ ansible-playbook test.yml -k
SSH password: 

PLAY [Device Version] *********************************************************************************************************************************************************************************************

TASK [show version] ***********************************************************************************************************************************************************************************************
changed: [s1]

TASK [debug] ******************************************************************************************************************************************************************************************************
ok: [s1] => {
    "print_output.stdout_lines": []
}                                                                           <--DOESN'T DISPLAY ANY OUTPUT

PLAY RECAP ********************************************************************************************************************************************************************************************************
s1                    : ok=2    changed=1    unreachable=0    failed=0  



root@ubuntu:~$ cat ansible.cfg 

[defaults]


inventory = ./hosts

host_key_checking = false

timeout = 5


root@ubuntu:~$ cat hosts 

s1 ansible_ssh_common_args="-c 3des-cbc"


root@ubuntu:~$ cat test.yml

---

- name: Device Version

  hosts: rs301s1

  gather_facts: false

  

  tasks:

   - name: show version

     raw: "show version"


     register: print_output


   - debug: var=print_output.stdout_lines



I tried it on the following operation systems with the same results:


Ubuntu 18.04 LTS                                            ansible 2.5.5

CentOS Linux release 7.5.1804                       ansible 2.4.2.0


Ganesh Nalawade

unread,
Jun 26, 2018, 3:46:17 AM6/26/18
to Ansible Project

Based on the commands it seems you are trying to run commands that are meant to work with network devices.
If that's the case raw module does not work with network devices.

You need to set correct value of ansible_connection and use supported <network-os-name>_command or <network-os-name>_config
modules to run operational and configuration command respectively.

Also, please refer getting started guide for Ansible Network Automation https://docs.ansible.com/ansible/2.5/network/getting_started/index.html
for more details

Regards,
Ganesh

Ajay Kumar Manukonda

unread,
Aug 3, 2018, 7:52:18 PM8/3/18
to ansible...@googlegroups.com
Hi Ganesh,

Thanks for suggesting me the right resources to get started with ansible automation for network devices. The problem is we run a multi-vendor environment and this particular issue only occurs with Dell Force10 devices running "Force10 Operating System". I still wasn't able to find an easy way to get them working, although they kind of work when using "dellos9" network module along with public key authentication. I need to do some more tests.

Sorry for the delayed response.

Regards,
Ajay

P.S. "raw" module works for some network devices although it has some limitations.

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/1OT0N_I1qlc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f9456750-fb46-4105-a664-26f63c0b2447%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages