ios_command by ansible

Hey Folks,

Trying to get sh int des | i by ansible.

my ansible play is adding the special character which didn’t work on the switch.

debug: sample output
“commands”: [
“sh int des |i "host161|host162"”

I would like to remove the special character """ in the playbook itself. is there a way to do ?

play:
rgs.txt contains two lines hostname
host161
host162

vars:
result: “{{ lookup(‘file’, ‘rgs.txt’) | regex_replace(‘[\r\n\t]+’,‘|’) }}”

  • name: Run network commands
    ios_command:
    commands: sh int des |i “{{ result }}”

Thanks,
Ramesh

Hey Ramesh,
This is a known issue for the ios_command module, the way the command and responses are formatted causes the issue you are facing, The solution to this is a bit tricky we are looking forward to fixing it.
You may draft a GitHub issue here to keep track of this issue.

Regards,
Sagar Paul
E - sagpaul@redhat.com
G - KB-perByte