cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
6893
Views
17
Helpful
5
Replies

Ansible IOS_Command issues

SO it's been a bit since I had "played" around with ansible, probably like 2.4 or 2.5. Now it seems we are at version 2.9. Is the ios_command module changed or not available anymore?

 

I keep getting this error when I am trying to run a simple "show arp" command. 

 

atal: [vIOS04]: 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"}

 

So I am trying to figure out where this issue is and what needs to be fixed. 

 

5 Replies 5

Claudia de Luna
Spotlight
Spotlight

Hi @stevenjwilliams0728,

 

Yes! Many changes and now version 2.10 is out tool which has some major restructuring.  But you mentioned 2.9 so I know this playbook works on 2.9.  

 

Using this repository and specifically this playbook, ios_show_lab_brief.yml which shows the old provider syntax (commented out) but uses the new method (much more server like) you should be able to run your show arp command like I did below.

 

If you want to use the Docker image you can find that here or use your existing 2.0 control server.  If you use the container, it comes with a few sample repositories including the cisco_ios one I mentioned.  Note: I did edit the show commands to just run "show arp".

 

I then to learn by examples so I hope this helps.

 

 

claudia@Claudias-iMac ~ % docker run -it cldeluna/disco-immigrant
root@e340c7ef8161:/ansible_local# cd cisco_ios/
root@e340c7ef8161:/ansible_local/cisco_ios# vi ios_show_lab_brief.yml
root@e340c7ef8161:/ansible_local/cisco_ios# ansible-playbook -i hosts ios_show_lab_brief.yml

PLAY [Pull show commands form Cisco IOS_XE Always On Sandbox device] ***********

TASK [Iterate over show commands] **********************************************
ok: [ios-xe-mgmt.cisco.com] => (item=show arp)

TASK [debug] *******************************************************************
ok: [ios-xe-mgmt.cisco.com] => {
    "output": {
        "changed": false,
        "deprecations": [
            {
                "msg": "Distribution Ubuntu 19.04 on host ios-xe-mgmt.cisco.com should use /usr/bin/python3, but is using /usr/bin/python for backward compatibility with prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information",
                "version": "2.12"
            }
        ],
        "msg": "All items completed",
        "results": [
            {
                "ansible_facts": {
                    "discovered_interpreter_python": "/usr/bin/python"
                },
                "ansible_loop_var": "item",
                "changed": false,
                "failed": false,
                "invocation": {
                    "module_args": {
                        "auth_pass": null,
                        "authorize": null,
                        "commands": [
                            "show arp"
                        ],
                        "host": null,
                        "interval": 1,
                        "match": "all",
                        "password": null,
                        "port": null,
                        "provider": null,
                        "retries": 10,
                        "ssh_keyfile": null,
                        "timeout": null,
                        "username": null,
                        "wait_for": null
                    }
                },
                "item": "show arp",
                "stdout": [
                    "Protocol  Address          Age (min)  Hardware Addr   Type   Interface\nInternet  10.10.20.48             -   0050.56bb.e14e  ARPA   GigabitEthernet1\nInternet  10.10.20.253            1   0896.ad9e.444c  ARPA   GigabitEthernet1\nInternet  10.10.20.254          227   0008.e3ff.fd90  ARPA   GigabitEthernet1"
                ],
                "stdout_lines": [
                    [
                        "Protocol  Address          Age (min)  Hardware Addr   Type   Interface",
                        "Internet  10.10.20.48             -   0050.56bb.e14e  ARPA   GigabitEthernet1",
                        "Internet  10.10.20.253            1   0896.ad9e.444c  ARPA   GigabitEthernet1",
                        "Internet  10.10.20.254          227   0008.e3ff.fd90  ARPA   GigabitEthernet1"
                    ]
                ]
            }
        ]
    }
}

TASK [copy] ********************************************************************
changed: [ios-xe-mgmt.cisco.com -> localhost]

TASK [copy] ********************************************************************
changed: [ios-xe-mgmt.cisco.com -> localhost]

TASK [Generate Device Show Command File(s)] ************************************
changed: [ios-xe-mgmt.cisco.com] => (item={'msg': u'All items completed', 'deprecations': [{'msg': u'Distribution Ubuntu 19.04 on host ios-xe-mgmt.cisco.com should use /usr/bin/python3, but is using /usr/bin/python for backward compatibility with prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information', 'version': u'2.12'}], 'changed': False, 'results': [{'ansible_loop_var': u'item', u'stdout': [u'Protocol  Address          Age (min)  Hardware Addr   Type   Interface\nInternet  10.10.20.48             -   0050.56bb.e14e  ARPA   GigabitEthernet1\nInternet  10.10.20.253            1   0896.ad9e.444c  ARPA   GigabitEthernet1\nInternet  10.10.20.254          227   0008.e3ff.fd90  ARPA   GigabitEthernet1'], u'changed': False, 'failed': False, 'item': u'show arp', u'invocation': {u'module_args': {u'username': None, u'authorize': None, u'commands': [u'show arp'], u'interval': 1, u'retries': 10, u'auth_pass': None, u'wait_for': None, u'host': None, u'ssh_keyfile': None, u'timeout': None, u'provider': None, u'password': None, u'port': None, u'match': u'all'}}, u'stdout_lines': [[u'Protocol  Address          Age (min)  Hardware Addr   Type   Interface', u'Internet  10.10.20.48             -   0050.56bb.e14e  ARPA   GigabitEthernet1', u'Internet  10.10.20.253            1   0896.ad9e.444c  ARPA   GigabitEthernet1', u'Internet  10.10.20.254          227   0008.e3ff.fd90  ARPA   GigabitEthernet1']], 'ansible_facts': {u'discovered_interpreter_python': u'/usr/bin/python'}}]})

PLAY RECAP *********************************************************************
ios-xe-mgmt.cisco.com      : ok=5    changed=3    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

root@e340c7ef8161:/ansible_local/cisco_ios#

Sergey Lisitsin
VIP Alumni
VIP Alumni

Hi stevenjwilliams0728,

 

It looks like your issue is with incorrect indentation. You are trying to use "register" keyword to create a variable from the output of your command, but that parameter needs to be on the level of the task name, not under the module name. So if you have something like this:

 

- name: Get some output and register it

  ios_command:

    command: show ip route

    register: ip_route

 

It should look like that:

 

- name: Get some output and register it

  ios_command:

    command: show ip route

  register: ip_route

 

As you can see, the indentation of "register" keyword is in line with the module name, not further.

Ok that fixed it. Is there some kind of extension/Module in vscode to help with spacing? I feel like I get caught up on that quite often.

 

 

Well, unfortunately the text editor can't decode the hierarchy of your dictionary in YAML, so I don't think so. The only thing that it can do is keep your current indentation level, but that won't help.

 

@Sergey Lisitsin

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.

. Its better to refer the standard ansible documentations.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: