Help with Basic IOS Command module

If anyone is able to assist i would really appreciate it, I have spent hours looking around ,fixing random things and still cannot find why my script errors out on a 'type error"…

/etc/ansible/cisco$ cat tasks.yml

  • hosts: all
    gather_facts: no
    tasks:
  • name: ios command
    ios_command:
    commands:
  • terminal length 0
  • show interfaces

/etc/ansible/cisco$ cat hosts
[ios]
coreswitch ansible_host=10.0.99.2 ansible_ssh_pass=password ansible_user=ansible

Hi bain,

Looks like your missing connection: local in your playbook. See updated below:

  • hosts: all
    gather_facts: no
    tasks:
  • name: ios command
    ios_command:
    connection: local
    commands:
  • terminal length 0
  • show interfaces

Hello All,

I am trying using ios_command to get “show running”, however all the time task overwrite on the same file ( like txt ).

For example would like create file for each day? Which function I could use?

Kind Regards,
Rodrigo

Hi Bain,

It seems the ios_command module doesn’t work with Python3.5. Try running it with Python2.7.

Regards,Sergey

Hi Sergey, can you provide more details about what isn’t working in py3.5?

Hi Peter,

persistent.py module raises the following exception:

File "/Users/sbondar/anaconda/envs/ansibleenv4/lib/python3.5/site-packages/ansible/plugins/connection/persistent.py", line 56, in _do_it
    cPickle.dump(self._play_context.serialize(), src)
TypeError: string argument expected, got 'bytes'

I’ve filed a bug report for this issue, more details there:

https://github.com/ansible/ansible/issues/24355

Cheers,
Sergey