How to avoid backslash and quote from variable

14 views
Skip to first unread message

bikram40

unread,
Apr 1, 2019, 10:58:44 PM4/1/19
to ansible...@googlegroups.com
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


P. Varsha

unread,
Apr 3, 2019, 2:28:42 AM4/3/19
to ansible...@googlegroups.com
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


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAEFfMJTTQEjjBHUq_iXjPSH5iAwB6unSYws%2BrKbk%2B79Eg2e58Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

bikram40

unread,
Apr 3, 2019, 9:07:54 AM4/3/19
to ansible...@googlegroups.com
Hi 
Thanks for your feedback 
I solved it using regular expression 

Bikram

Sent from my iPhone
Reply all
Reply to author
Forward
0 new messages