Unless you have a very old F5, you'd probably be better off gathering facts 
from the f5 - the console output looks really hard to parse.  
https://docs.ansible.com/ansible/latest/modules/bigip_device_facts_module.html


On Thursday, June 13, 2019 at 5:58:31 PM UTC+1, Kethan R wrote:
>
> I already used it, but still im getting output in this format which i 
> cannot filter it ...
>
> [image: lb.PNG]
>
>   tasks:
>     - name: print date
>       set_fact: temp="{{lookup('pipe','date \"+%Y-%m-%d-%H-%M\"')}}"
>     - name: creates file
>       file: 
>         path: "/tmp/loadbalancer_{{ temp }}.csv"
>         state: touch
>     - name: creates file
>       file: 
>         path: "/tmp/loadbalancer_{{ temp }}.txt"
>         state: touch
>     - name: print date
>       set_fact: files="loadbalancer_{{ temp }}.csv"
>     - name: Run Health Checks on LoadBalancer servers
>       bigip_command:
>         commands:
>           - show sys version
>           - show sys service | grep tmm
>           - show ltm
>           - show sys memory
>         provider:
>           server: xxxx.xxxx
>           password: "{{ xxxxx }}"
>           user: "{{ xxxxx }}"
>           validate_certs: no    
>       register: version
>       delegate_to: localhost
>     - name: Updating variable
>       copy: content="{{ version.stdout_lines | to_nice_yaml }}" 
> dest="/tmp/loadbalancer_{{ temp }}.txt"
>     - name: Parse the CSV file
>       shell: 
>         cmd: |
>           cp -f "/tmp/loadbalancer_{{ temp }}.txt" /tmp/temp.txt
>           cat /tmp/temp.txt| tr -s '[:blank:]' ' ' > "/tmp/loadbalancer_{{ 
> temp }}.csv" 
>
> On Thursday, June 13, 2019 at 11:31:46 AM UTC-5, J Hawkesworth wrote:
>>
>>
>> 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 investigating are the lookups that ansible has.  See 
>> https://docs.ansible.com/ansible/latest/plugins/lookup.html You might 
>> want to use 
>> https://docs.ansible.com/ansible/latest/plugins/lookup/csvfile.html to 
>> load the csv for further processing.
>>
>> 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.
>>
>> Hope this helps,
>>
>> Jon
>>
>>
>> On Thursday, June 13, 2019 at 4:19:49 PM UTC+1, Kethan R wrote:
>>>
>>> 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.
>>>
>>>
>>> EX:
>>> xxx::Node: IP.ip.ip.ip (ip.ip.ip.ip) 
>>> ------------------------------------------ 
>>> Status 
>>> Availability : available 
>>> State : enabled 
>>> Reason : Node address is available
>>> Monitor : /Common/icmp (default node monitor)
>>> Monitor Status : up 
>>> Session Status : enabled 
>>> Traffic  ServerSide General 
>>> Bits In 0   - 
>>> Bits Out 0   - 
>>> Packets In 0   - 
>>> Packets Out 0   - 
>>> Current Connections 0   - 
>>> Maximum Connections 0   - 
>>> Total Connections 0   - 
>>> Total Requests -   0 
>>> Current Sessions -   0 
>>>
>>

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ae1018ac-46ec-4f35-b357-65f4c5ceabd1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to