How to avoid backslash and quote from variable

Hello,

I am running an audit against some interfaces on Cisco switches:
Here is the task:

  • ios_command:
    provider: “{{ cli }}”
    commands: show run interface “{{ item }}” | i no cdp
    timeout: 15
    register: no_cdp
    with_items: “{{ interface_all.stdout_lines }}”

From with_items the value of variables passing as “show run interface "Gi9/1" | i no cdp” which gives me an error as it has " in both leading and trailing side of interface name.

I tried | regex_replace after item to avoid these two characters but no luck.

Could you please help.

Thanks,
Bikram Biswas

Hello,
I am not working on cisco switches but try once - "show run interface “\Gi9/1" | i no cdp” .
check your commands once your using - "show run interface " right because of that you got error.

Thanks

Hi
Thanks for your feedback
I solved it using regular expression

Bikram