- hosts: localhost
connection: local
gather_facts: no
vars:
input: |-
404135 ARP requests sent
6762 ARP replies sent
6762 ARP requests received
0 ARP requests ignored
tasks:
- debug: var=input
- set_fact:
var2: "{{ '404135 ARP requests sent' | map('regex_replace','(\\d+)ARP requests sent','ARPRequestsSent: \\1') }}"
I'm looking to manipulate and convert to JSON format using the regex replace plugin we can manipulate the data and how can we change string positions and get into the desired format of the output
{
"ARP_Requests_Sent": "404135",
"ARP_replies_sent": "6762",
"ARP_requests_received": "6762",
"ARP_requests_ignored": "0"
}
Any leads are helpful