# TTP parsing doesn't work in ansible, need assistance

**URL:** <https://forum.ansible.com/t/ttp-parsing-doesnt-work-in-ansible-need-assistance/35022>\
**Category:** Ansible Project\
**Created:** [April 21, 2021, 10:04am UTC](https://forum.ansible.com/t/ttp-parsing-doesnt-work-in-ansible-need-assistance/35022 "2021-04-21T10:04:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vikram\_S](https://avatars.discourse-cdn.com/v4/letter/v/90db22/32.png) [@Vikram\_S](https://forum.ansible.com/u/Vikram_S)\
**Post date:** [April 21, 2021, 10:04am UTC](https://forum.ansible.com/t/ttp-parsing-doesnt-work-in-ansible-need-assistance/35022/1 "2021-04-21T10:04:13Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Pushparaj\_Gothandam](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/pushparaj_gothandam/32/5538_2.png) [@Pushparaj\_Gothandam](https://forum.ansible.com/u/Pushparaj_Gothandam)\
**Post date:** [April 21, 2021, 11:29am UTC](https://forum.ansible.com/t/ttp-parsing-doesnt-work-in-ansible-need-assistance/35022/2 "2021-04-21T11:29:34Z")

</div>

try removing quotes in stdout

---

<div class="post-metadata">

**Author:** ![Komal\_Suthar](https://avatars.discourse-cdn.com/v4/letter/k/919ad9/32.png) [@Komal\_Suthar](https://forum.ansible.com/u/Komal_Suthar)\
**Post date:** [April 21, 2021, 2:03pm UTC](https://forum.ansible.com/t/ttp-parsing-doesnt-work-in-ansible-need-assistance/35022/3 "2021-04-21T14:03:30Z")

</div>

“{{ show\_space.stdout }}” try in this way

---

<div class="post-metadata">

**Author:** ![Vikram\_S](https://avatars.discourse-cdn.com/v4/letter/v/90db22/32.png) [@Vikram\_S](https://forum.ansible.com/u/Vikram_S)\
**Post date:** [April 21, 2021, 2:17pm UTC](https://forum.ansible.com/t/ttp-parsing-doesnt-work-in-ansible-need-assistance/35022/4 "2021-04-21T14:17:43Z")

</div>

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
