Re: [ansible-project] No output from Cisco router

1,003 views
Skip to first unread message

Peter Sprygada

unread,
Oct 30, 2017, 8:06:48 AM10/30/17
to ansible...@googlegroups.com
run with -v (or -vvv) to see the output of the task on the command line


On Thu, Oct 26, 2017 at 9:41 AM, <pateld...@gmail.com> wrote:


On Thursday, October 26, 2017 at 9:39:37 AM UTC-4, pateld...@gmail.com wrote:
Hello Friends,

I've just picked up network automation with ansible and this is my first attempt to build a very simple playbook to run "show version" on Cisco IOS router.Although, playbook runs successfully but i can't see any output from the router when playbook runs

----> ansible-playbook -i inventory config.yml
[DEPRECATION WARNING]: [defaults]hostfile option, The key is misleading as it can also be a list of
hosts, a directory or a list of paths . This feature will be removed in version 2.8. Deprecation warnings
 can be disabled by setting deprecation_warnings=False in ansible.cfg.

PLAY [RUNNING CONFIG] ************************************************************************************

TASK [SHOW CONFIGURATION] ********************************************************************************
 [WARNING]: argument username has been deprecated and will be removed in a future version

 [WARNING]: argument host has been deprecated and will be removed in a future version

 [WARNING]: argument password has been deprecated and will be removed in a future version

ok: [switch1]

PLAY RECAP ***********************************************************************************************
switch1                    : ok=1    changed=0    unreachable=0    failed=0  


My YAML file:-


cat config.yml
---

 - name: RUNNING CONFIG
   hosts: ios
   gather_facts: no
   connection: local

   tasks:
  
   - name: SHOW CONFIGURATION
     ios_command:
      commands:
        - show version
        - show interface summary

      username: "{{ un }}"
      password: "{{ pwd }}"
      host: "{{ inventory_hostname }}"

Am i missing something? Appreciate your support.

Thanks,
Dipak

--
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 ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/49b14432-3fbb-4342-9671-962e3e2bfd4a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Karn Kumar

unread,
Oct 30, 2017, 10:32:34 AM10/30/17
to Ansible Project
where is your password and username saved?  there should be a template for these?
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

Karn Kumar

unread,
Oct 30, 2017, 10:40:16 AM10/30/17
to Ansible Project
try below.. you need  to register the output & the use debug to display the stdout of register...

---
 - name: Checking running cisco config
   hosts: ios
   gather_facts: no
   connection: local
   tasks:
   - name: SHOW CONFIGURATION
     ios_command:
       commands:
         - show version
         - show interface summary
       username: "{{ un }}"
       password: "{{ pwd }}"
       host: "{{ inventory_hostname }}"
       register: ios_out

   - debug: msg="{{ ios_out.stdout }}"


On Monday, October 30, 2017 at 5:36:48 PM UTC+5:30, Peter Sprygada wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

SK

unread,
Dec 8, 2017, 3:10:56 AM12/8/17
to Ansible Project
Hi,

I am also facing a similar problem.  The output says "register" is not supported for ios_command module.  Any idea on this?  I am running the latest ansible version 2.4.2.0.  If I don't use the register command, the playbook executes successfully, so the error is only caused by register/stdout related commands.

Appreciate any help.


---
 - name: Checking running cisco config
   hosts: cisco
   gather_facts: False
   connection: local
   vars_files:
   - creds.yml

   tasks:


      - name: configure provider
        set_fact:
         provider:
           username: "{{username}}"
           password: "{{password}}"
           host: "{{inventory_hostname}}"


      - name: DEPLOY SNMP COMMANDS WITHIN PB
        delegate_to: localhost
        ios_command:
           provider: "{{ provider }}"
           commands:
             - show mod | i c200
           register: showmod

      - debug: "msg='2c31.24a4.c200'"
        when: showmod.stdout | join(" ") | search("/c200/")




PLAY [Checking running cisco config] ********************************************************************************************************************************************************************************************************

TASK [configure provider] *******************************************************************************************************************************************************************************************************************
ok: [sltnrmgmt]

TASK [DEPLOY SNMP COMMANDS WITHIN PB] *******************************************************************************************************************************************************************************************************
fatal: [sltnrmgmt -> localhost]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (ios_command) module: register Supported parameters include: auth_pass,authorize,commands,host,interval,match,password,port,provider,retries,ssh_keyfile,timeout,username,wait_for"}
        to retry, use: --limit @/etc/ansible/cisco-test.retry

PLAY RECAP **********************************************************************************************************************************************************************************************************************************
sltnrmgmt      : ok=1    changed=0    unreachable=0    failed=1


ansible --version
ansible 2.4.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Nov  6 2016, 00:28:07) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]

Kai Stian Olstad

unread,
Dec 8, 2017, 3:19:41 AM12/8/17
to ansible...@googlegroups.com
register is a directive for the task and not the module.
So the register is indented to spaces to much, it should be on the same level as ios_command, delegate_to and name.


--
Kai Stian Olstad

SK

unread,
Dec 8, 2017, 4:10:12 AM12/8/17
to Ansible Project
Excellent!  Many thanks for the pointer and it is working now.  Is there any link that you could provide me regarding the best practices for indendations?

Kai Stian Olstad

unread,
Dec 8, 2017, 4:27:15 AM12/8/17
to ansible...@googlegroups.com
On 08.12.2017 10:10, SK wrote:
> Excellent! Many thanks for the pointer and it is working now. Is
> there
> any link that you could provide me regarding the best practices for
> indendations?

You have the YAML specification that says it must be space and you need
to be consistent on the number of spaces you use.

For Ansible you have the list[1] that list all directives and where you
can use them.
What you can use on the module it self is documented under each module.

So for register, you'll not find that documented under ios_command so
you can't have under the module. But if you check the link you'll see
that register on can be used on the task.


[1] http://docs.ansible.com/ansible/latest/playbooks_keywords.html

--
Kai Stian Olstad

Kazi Sohel Hasan

unread,
Feb 20, 2020, 6:33:28 AM2/20/20
to Ansible Project
I am getting following error:

fatal: [210.4.64.100]: FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "invocation": {
        "module_args": {
            "command": "show version"
        }
    },
    "msg": "Unsupported parameters for (ios_command) module: command Supported parameters include: auth_pass, authorize, commands, host, interval, match, password, port, provider, retries, ssh_keyfile, timeout, username, wait_for"
}

PLAY RECAP *************************************************************************************************************************************************************
210.4.64.100               : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

Someone please assist me 
To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

Stefan Hornburg (Racke)

unread,
Feb 20, 2020, 6:41:49 AM2/20/20
to ansible...@googlegroups.com
On 2/20/20 12:33 PM, Kazi Sohel Hasan wrote:
> I am getting following error:
>
> fatal: [210.4.64.100]: FAILED! => {
>     "ansible_facts": {
>         "discovered_interpreter_python": "/usr/bin/python"
>     },
>     "changed": false,
>     "invocation": {
>         "module_args": {
>             "command": "show version"
>         }
>     },
>     "msg": "Unsupported parameters for (ios_command) module: command Supported parameters include: auth_pass, authorize,
> commands, host, interval, match, password, port, provider, retries, ssh_keyfile, timeout, username, wait_for"
> }

The error message really points out the mistake in your playbook.

Regards
Racke

>
> PLAY RECAP
> *************************************************************************************************************************************************************
> 210.4.64.100               : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0
>
> Someone please assist me 
>
> On Monday, October 30, 2017 at 6:06:48 PM UTC+6, Peter Sprygada wrote:
>
> run with -v (or -vvv) to see the output of the task on the command line
>
> use register to further process the output
> (http://docs.ansible.com/ansible/latest/playbooks_variables.html#registered-variables
> <http://docs.ansible.com/ansible/latest/playbooks_variables.html#registered-variables>)
>
> On Thu, Oct 26, 2017 at 9:41 AM, <pateld...@gmail.com <javascript:>> wrote:
>
>
>
> On Thursday, October 26, 2017 at 9:39:37 AM UTC-4, pateld...@gmail.com wrote:
>
> Hello Friends,
>
> I've just picked up network automation with ansible and this is my first attempt to build a very simple
> playbook to run "show version" on Cisco IOS router.Although, playbook runs successfully but i can't see any
> output from the router when playbook runs
>
> ----> ansible-playbook -i inventory config.yml
> [DEPRECATION WARNING]: [defaults]hostfile option, The key is misleading as it can also be a list of
> hosts, a directory or a list of paths . This feature will be removed in version 2.8. Deprecation warnings
>  can be disabled by setting deprecation_warnings=False in ansible.cfg.
>
> PLAY [RUNNING CONFIG] ************************************************************************************
>
> TASK [SHOW CONFIGURATION] ********************************************************************************
>  [WARNING]: argument username has been deprecated and will be removed in a future version
>
>  [WARNING]: argument host has been deprecated and will be removed in a future version
>
>  [WARNING]: argument password has been deprecated and will be removed in a future version
>
> ok: [switch1]
>
> PLAY RECAP ***********************************************************************************************
> switch1                    : ok=1    changed=0    unreachable=0    failed=0  
>
> *
> My YAML file:-*
>
> cat config.yml
> ---
>
>  - name: RUNNING CONFIG
>    hosts: ios
>    gather_facts: no
>    connection: local
>
>    tasks:
>   
>    - name: SHOW CONFIGURATION
>      ios_command:
>       commands:
>         - show version
>         - show interface summary
>       username: "{{ un }}"
>       password: "{{ pwd }}"
>       host: "{{ inventory_hostname }}"
>
> Am i missing something? Appreciate your support.
>
> Thanks,
> Dipak
>
> --
> 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 ansible...@googlegroups.com
> <javascript:>.
> To post to this group, send email to ansible...@googlegroups.com <javascript:>.
> <https://groups.google.com/d/msgid/ansible-project/49b14432-3fbb-4342-9671-962e3e2bfd4a%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout <https://groups.google.com/d/optout>.
>
>
> --
> 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
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/2e057437-0197-4add-9545-77ede0eb1631%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/2e057437-0197-4add-9545-77ede0eb1631%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

signature.asc

Vladimir Botka

unread,
Feb 20, 2020, 6:49:42 AM2/20/20
to Kazi Sohel Hasan, ansible...@googlegroups.com
On Thu, 20 Feb 2020 03:33:28 -0800 (PST)
Kazi Sohel Hasan <qua...@gmail.com> wrote:

> [...]
> "invocation": {
> "module_args": {
> "command": "show version"
> }
> },
> "msg": "Unsupported parameters for (ios_command) module: command
> Supported parameters include: auth_pass, authorize, commands, host,
> interval, match, password, port, provider, retries, ssh_keyfile, timeout,
> username, wait_for"
> }

Should be "commands" instead of "command", probably?

HTH,

-vlado

Kazi Sohel Hasan

unread,
Feb 20, 2020, 7:01:41 AM2/20/20
to ansible...@googlegroups.com
Here is my playbook, would you please check ?

---
- name: First Play
  hosts: cisco
  gather_facts: False
  connection: local
  tasks:
   - name: First Task
     ios_command:
         command: show version
     register: version
   - name: Second Task
     debug:
      var: version

To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/044894f2-72cb-3f37-1740-8aea0843a5e6%40linuxia.de.


--
Best Regards,

Kazi Sohel Hasan
Cell: 01993442004
Message has been deleted

Dushyant

unread,
Mar 21, 2020, 4:38:28 AM3/21/20
to Ansible Project
Hello Kazi,

The following error indicates that during the execution of ios_command module an unsupported parameter 'command' was found. Do check the Ansible document [1] for the support parameters in the ios_command module.

    --------------------------------------
    "msg": "Unsupported parameters for (ios_command) module: command Supported parameters include: auth_pass, authorize, commands, host, interval, match, password, port, provider, retries, ssh_keyfile, timeout, username, wait_for"
    --------------------------------------

After looking at your playbook 'command' is not supported in ios_command module 'commands' is the correct parameter.

For your reference below is the snippet of how the code should look:

    --------------------------------------
    ...
    tasks:
    - name: First Task
        ios_command:
            commands: show version
    ...
    --------------------------------------

Reference:

> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/2e057437-0197-4add-9545-77ede0eb1631%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/2e057437-0197-4add-9545-77ede0eb1631%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

--
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 ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages