Recently i wrote a playbook to pull the data from Loadbalancer server.
Output is saving in 1st row of each column.
output has : data separated with spaces, Tabs and :
I want to apply delimit option only on tabs spaces and : which i am not able to. Kindly suggest if you have any solution.
Assuming you have the data from your load balancer stored in a registered variable you could run copy to write the file to disk on the controller, and then a shell task to use ‘tr’ command to convert the whitespace, tabs and : to a comma, and then you would have .csv file you could process. Something like the following (which I have NOT tested):
`
name: copy loadbalancer output to disk
copy:
content: “{{ output_from_load_balancer }}”
dest: /tmp/load-balancer-raw
delegate_to: localhost
name: make raw loadbalancer into csv
shell: cat /tmp/load-balancer-raw | tr [:blank:] , | tr : , > /tmp/load-balancer-raw
delegate_to: localhost
`
Also worth exploring to see if you can get more structured data out of your load balancer, preferably json or yaml, both of which are much easier to then use within ansible.