Tried however doesnt work.
=> template error while templating string: expected name or number. String:
{{{output.results._ansible_item_label.{item}}}}'
On Thursday, January 24, 2019 at 7:01:04 PM UTC+5:30, Karthik Chandrashekar
wrote:
>
> May be you could try something like this. Register your output to some
> variable let's call it X. Then try to debug like below example.
> Am exactly sure but, you can give a try.
>
> var="{X.results._ansible_item_label.{item}}"
> with_item:
> - packet_lose
> - packet_rx
>
> On Thu 24 Jan, 2019, 6:51 PM Diptajeet Khan <[email protected]
> <javascript:> wrote:
>
>> Hi,
>>
>> Need help to fetch output from the below output message.
>>
>> Bascially I need to extract "packet_loss", "packets_rx", "packets_tx",
>> "rtt_avg", "rtt_max" & "rtt_min" for each "item".
>>
>> Trying to use the code as
>>
>> Code
>> =============:
>> - debug:
>> var: "{{ item['packet_loss'] }}"
>> with_items: "{{ output.results }}"
>> =============
>>
>> Output:
>> =============
>> "results": [
>> {
>> "_ansible_ignore_errors": null,
>> "_ansible_item_label": {
>> "count": 5,
>> "dst": "192.168.1.3",
>> "packet_loss": null,
>> "packets_rx": null,
>> "packets_tx": null,
>> "rtt_avg": null,
>> "rtt_max": null,
>> "rtt_min": null,
>> "source": "192.168.1.1"
>> },
>> "_ansible_item_result": true,
>> "_ansible_no_log": false,
>> "_ansible_parsed": true,
>> "changed": false,
>> "commands": [
>> "ping 192.168.1.3 count 5 source 192.168.1.1"
>> ],
>> "failed": false,
>> "invocation": {
>> "module_args": {
>> "auth_pass": null,
>> "authorize": null,
>> "count": "5",
>> "dest": "192.168.1.3",
>> "host": null,
>> "password": null,
>> "port": null,
>> "provider": null,
>> "source": "192.168.1.1",
>> "ssh_keyfile": null,
>> "state": "present",
>> "timeout": null,
>> "transport": null,
>> "use_ssl": null,
>> "username": null,
>> "validate_certs": null,
>> "vrf": null
>> }
>> },
>> "item": {
>> "count": 5,
>> "dst": "192.168.1.3",
>> "packet_loss": null,
>> "packets_rx": null,
>> "packets_tx": null,
>> "rtt_avg": null,
>> "rtt_max": null,
>> "rtt_min": null,
>> "source": "192.168.1.1"
>> },
>> "packet_loss": "0.00%",
>> "packets_rx": 5,
>> "packets_tx": 5,
>> "rtt": {
>> "avg": 0.67,
>> "max": 0.876,
>> "min": 0.585
>> }
>> },
>> {
>> "_ansible_ignore_errors": null,
>> "_ansible_item_label": {
>> "count": "N/A",
>> "dst": "N/A",
>> "packet_loss": null,
>> "packets_rx": null,
>> "packets_tx": null,
>> "rtt_avg": null,
>> "rtt_max": null,
>> "rtt_min": null,
>> "source": "N/A"
>> },
>> "_ansible_item_result": true,
>> "_ansible_no_log": false,
>> "changed": false,
>> "item": {
>> "count": "N/A",
>> "dst": "N/A",
>> "packet_loss": null,
>> "packets_rx": null,
>> "packets_tx": null,
>> "rtt_avg": null,
>> "rtt_max": null,
>> "rtt_min": null,
>> "source": "N/A"
>> },
>> "skip_reason": "Conditional result was False",
>> "skipped": true
>> },
>> {
>> "_ansible_ignore_errors": null,
>> "_ansible_item_label": {
>> "count": "N/A",
>> "dst": "N/A",
>> "packet_loss": null,
>> "packets_rx": null,
>> "packets_tx": null,
>> "rtt_avg": null,
>> "rtt_max": null,
>> "rtt_min": null,
>> "source": "N/A"
>> },
>> "_ansible_item_result": true,
>> "_ansible_no_log": false,
>> "changed": false,
>> "item": {
>> "count": "N/A",
>> "dst": "N/A",
>> "packet_loss": null,
>> "packets_rx": null,
>> "packets_tx": null,
>> "rtt_avg": null,
>> "rtt_max": null,
>> "rtt_min": null,
>> "source": "N/A"
>> },
>> "skip_reason": "Conditional result was False",
>> "skipped": true
>> },
>> {
>> "_ansible_ignore_errors": null,
>> "_ansible_item_label": {
>> "count": "N/A",
>> "dst": "N/A",
>> "packet_loss": null,
>> "packets_rx": null,
>> "packets_tx": null,
>> "rtt_avg": null,
>> "rtt_max": null,
>> "rtt_min": null,
>> "source": "N/A"
>> },
>> "_ansible_item_result": true,
>> "_ansible_no_log": false,
>> "changed": false,
>> "item": {
>> "count": "N/A",
>> "dst": "N/A",
>> "packet_loss": null,
>> "packets_rx": null,
>> "packets_tx": null,
>> "rtt_avg": null,
>> "rtt_max": null,
>> "rtt_min": null,
>> "source": "N/A"
>> },
>> "skip_reason": "Conditional result was False",
>> "skipped": true
>> ==================
>>
>> --
>> 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] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/c6b832fd-47e8-4a10-87a4-1ef6aa868f02%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/ansible-project/c6b832fd-47e8-4a10-87a4-1ef6aa868f02%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
--
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/665c1b6e-2746-409a-8959-e452d9c1abf3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.