Hi Pushparaj,

TRhanks for your suggestion, modifying syntax helped!!
But it's ironical that ansible's own documentation would give wrong syntax 
as earlier syntax was taken from sample example given in ansible site.

Below is the output i get, how do i compare value of 'bytes_free' to a 
number? i wrote the below syntax but didn't work.
   - assert:
        that:
        - parser_output['flash:']['bytes_free'] > 440320
        fail_msg: "DEVICE MODEL IS NOT 2960x. SO PLAYBOOK IS ENDING."

*WORKING SCRIPT:*
TASK [Display facts] 
**********************************************************************************************************************************************************************************************
ok: [SW6] => {
    "msg": [
        [
            {
                "flash:/": {
                    "bytes_free": 22840320,
                    "bytes_total": 122185728

- name: Pass text and template_path
      ansible.utils.cli_parse:
        text: "{{ show_space.stdout[0] }}"
        parser:
          name: ansible.utils.ttp
          template_path: "templates/sample2.ttp"

      register: parser_output


Thanks,
Vikram

On Wednesday, 21 April, 2021 at 5:00:00 pm UTC+5:30 rajthecomputerguy wrote:

> try removing quotes in stdout
>
>
>
> On Wed, Apr 21, 2021 at 3:34 PM Vikram S <vikrams...@gmail.com> wrote:
>
>>
>> I wrote below script to parse output of 'sh flash:' however iam getting 
>> blank output. 
>>
>> I checked several examples and i seem to be following the format properly 
>> yet doesn't work. What am i doing wrong?
>>
>> *SCRIPT:*
>> ios_command:
>> commands: "show flash:"
>>
>> register: show_space
>>
>> name: Pass text and template_path
>> ansible.utils.cli_parse:
>> text: "{{ show_space['stdout'] }}"
>> parser:
>> name: ansible.utils.ttp
>> template_path: "templates/sample.ttp"
>>
>> register: parser_output
>>
>> name: Display facts
>> debug:
>> msg: "{{ parser_output.parsed }}"
>>
>> *TTP TEMPLATE:*
>> cat nano templates/sample.ttp
>> Directory of {{ path }}
>> {{ bytes_total }} bytes total ({{ bytes_free }} bytes free)
>> ----------------------------------------------------------------------
>> *OUTPUT:*
>> TASK [Display facts] *****************************************************
>> ok: [TEST2960] => {
>> "msg": [
>> [
>>      {} 
>>    ]
>>  ]
>> }
>>
>> Thanks,
>> Vikram
>>
>> -- 
>> 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 ansible-proje...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/14299988-a84c-468f-ac83-b89bf461f7ccn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/14299988-a84c-468f-ac83-b89bf461f7ccn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> -- 
>
> Thanks,
>
> Pushparaj G
>
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d27b1e76-177f-49a8-aa5f-5cbc8df7f732n%40googlegroups.com.

Reply via email to