ios_command by ansible

23 views
Skip to first unread message

Ramesh AR

unread,
May 11, 2022, 5:08:40 PM5/11/22
to Ansible Project
Hey Folks,

Trying to get sh int des | i <description> 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

Sagar Paul

unread,
May 24, 2022, 2:51:21 AM5/24/22
to Ansible Project
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
G - KB-perByte
Reply all
Reply to author
Forward
0 new messages