Ansible Jinja2 template - catch textfsm exception

57 views Asked by At

I'm using a textfsm filter inside a Jinja2 template to create a report. The textfsm filter can throw an exception, which stops the Jinja2 template from completing.

Below is how I call the textfsm filter in the Jinja2 template. The textfsm filter returns a list of dictionaries, which I print out in the template.

{% set structure = results.std_out[0] | parse_cli_textfsm(playbook_dir + '/template/cisco_ios_show_ip_arp.textfsm') %}

Is there a way to have the textfsm filter return a string of say 'ERROR' when an error occurs? I could then test for this and display an appropriate message. Basically, I'd like the template to complete despite the exception.

0

There are 0 answers