I'm trying to search for a specific string from a var and while it finds 
it, it prints the whole line and not the exact match I'm looking for. I'm 
running ansible 2.9 

Here is what it finds: *Interface GigabitEthernet0/1 "outside1", is up, 
line protocol is up*

And what I'm looking for is everything up to *",* or better yet any 
specific word in that line *Interface GigabitEthernet0/1 "outside1",*

Here is my template:


    {% for interface in show_interface.stdout_lines[0] %}
    {% if interface | regex_findall('Interface*.*\"\,',multiline=True) %}
    {{interface | string}}
    {% endif %}
    {% endfor %}

Here is my ansible-playbook task:

---
- name: execute firewall interface review
  asa_command:
    commands:
      - show interface | grep up
  register: show_interface

- name: print var data
  debug:
   var: show_interface.stdout_lines

- name: format interface data with template
  template:
    src: firewall_format.j2
    dest: ./firewall_interface_facts.txt
  delegate_to: localhost
'''

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/083c0243-d258-4001-b1ec-250ba2890083o%40googlegroups.com.

Reply via email to