- hosts: localhost
gather_facts: no
vars:
output: |
Routing entry for 2001:506:4200:4000::/50
Known via "static", distance 1, metric 0 (connected)
Installed Aug 12 12:39:44.252 for 8w6d
Routing Descriptor Blocks
directly connected, via Null0
Route metric is 0, Wt is 1
No advertising protos.
tasks:
- set_fact:
parse: "{{ output | map('regex_replace', 'Routing entry for (25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).*', 'Routing Entry: ') }}"
Not sure what's happening in the regex replace function
If once an object matches I can work on other objects, any leads are appreciated
I'm looking to get the output in the below format :
{
'Routing': '2001:506:4200:4000::/50',
'Installed': 'Aug 12 12:39:44.252',
'directly connected': 'via Null0',
'Route metric': '0'
}