# convert yaml file into jinja

**URL:** <https://forum.ansible.com/t/convert-yaml-file-into-jinja/29907>\
**Category:** Ansible Project\
**Tags:** windows, vmware\
**Created:** [March 19, 2019, 2:27am UTC](https://forum.ansible.com/t/convert-yaml-file-into-jinja/29907 "2019-03-19T02:27:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fmontaldo3](https://avatars.discourse-cdn.com/v4/letter/f/5f9b8f/32.png) [@fmontaldo3](https://forum.ansible.com/u/fmontaldo3)\
**Post date:** [March 19, 2019, 2:27am UTC](https://forum.ansible.com/t/convert-yaml-file-into-jinja/29907/1 "2019-03-19T02:27:43Z")

</div>

Hi Folks:

I want to know if there is a way to extract from a yaml file the disk information in order to pass it into jinja2 template. I got the following:

{  
“ansible\_facts”: {  
“ansible\_disks”: [  
{  
“bootable”: false,  
“bus\_type”: “SAS”,  
“clustered”: false,  
“firmware\_version”: "1.0 ",  
“friendly\_name”: “VMware Virtual disk SCSI Disk Device”,  
“guid”: null,  
“location”: “PCIROOT(0)#PCI(1500)#PCI(0000)#SAS(P00T01L00)”,  
“manufacturer”: "VMware ",  
“model”: "Virtual disk ",  
“number”: 1,  
“operational\_status”: “Offline”,  
“partition\_count”: 0,  
“partition\_style”: “RAW”,  
“path”: “\\?\scsi#disk&ven\_vmware&prod\_virtual\_disk#5&174a0eaf&0&000100#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}”,  
“physical\_disk”: {  
“allocated\_size”: 0,  
“bus\_type”: “SAS”,  
“can\_pool”: true,  
“device\_id”: “1”,  
“firmware\_version”: "1.0 ",  
“friendly\_name”: “PhysicalDisk1”,  
“health\_status”: “Healthy”,  
“indication\_enabled”: null,  
“manufacturer”: "VMware ",  
“media\_type”: “UnSpecified”,  
“model”: "Virtual disk ",  
“object\_id”: “{1}\\TCGNY-NE-DRVN2\root/Microsoft/Windows/Storage/Providers\_v2\SPACES\_PhysicalDisk.ObjectId="{98093284-f7ed-11e8-80b5-806e6f6e6963}:PD:{31d8233c-98dd-e50b-be04-4efda565d7a9}"”,  
“operational\_status”: “OK”,  
“partial”: false,  
“physical\_location”: null,  
“serial\_number”: “6000c29300845e830d442c17cbfff618”,  
“size”: 128849018880,  
“spindle\_speed”: 4294967295,  
“supported\_usages”: {  
“Count”: 5,  
“value”: [  
“Auto-Select”,  
“Manual-Select”,  
“Hot Spare”,  
“Retired”,  
“Journal”  
]  
},  
“unique\_id”: “6000C29300845E830D442C17CBFFF618”,  
“usage\_type”: “Auto-Select”  
},  
“read\_only”: true,  
“sector\_size”: 512,  
“serial\_number”: “6000c29300845e830d442c17cbfff618”,  
“size”: 128849018880,  
“system\_disk”: false,  
“unique\_id”: “6000C29300845E830D442C17CBFFF618”  
},  
{  
“bootable”: true,  
“bus\_type”: “SAS”,  
“clustered”: false,  
“firmware\_version”: "1.0 ",  
“friendly\_name”: “VMware Virtual disk SCSI Disk Device”,  
“guid”: null,  
“location”: “PCIROOT(0)#PCI(1500)#PCI(0000)#SAS(P00T00L00)”,  
“manufacturer”: "VMware ",  
“model”: "Virtual disk ",  
“number”: 0,  
“operational\_status”: “Online”,  
“partition\_count”: 2,  
“partition\_style”: “MBR”,  
“partitions”: [  
{  
“access\_paths”: [  
“\\?\Volume{9809328a-f7ed-11e8-80b5-806e6f6e6963}\”  
],  
“active”: true,  
“drive\_letter”: null,  
“guid”: null,  
“hidden”: false,  
“mbr\_type”: 7,  
“number”: 1,  
“offset”: 1048576,  
“shadow\_copy”: false,  
“size”: 367001600,  
“transition\_state”: 1,  
“type”: “IFS”,  
“volumes”: [  
{  
“allocation\_unit\_size”: 4096,  
“drive\_type”: “Fixed”,  
“health\_status”: “Healthy”,  
“label”: “System Reserved”,  
“object\_id”: “\\?\Volume{9809328a-f7ed-11e8-80b5-806e6f6e6963}\”,  
“path”: “\\?\Volume{9809328a-f7ed-11e8-80b5-806e6f6e6963}\”,  
“size”: 366997504,  
“size\_remaining”: 63823872,  
“type”: “NTFS”  
}  
]  
},  
{  
“access\_paths”: [  
“C:\”,  
“\\?\Volume{9809328b-f7ed-11e8-80b5-806e6f6e6963}\”  
],  
“active”: false,  
“drive\_letter”: “C”,  
“guid”: null,  
“hidden”: false,  
“mbr\_type”: 7,  
“number”: 2,  
“offset”: 368050176,  
“shadow\_copy”: false,  
“size”: 53317992448,  
“transition\_state”: 1,  
“type”: “IFS”,  
“volumes”: [  
{  
“allocation\_unit\_size”: 4096,  
“drive\_type”: “Fixed”,  
“health\_status”: “Healthy”,  
“label”: “”,  
“object\_id”: “\\?\Volume{9809328b-f7ed-11e8-80b5-806e6f6e6963}\”,  
“path”: “\\?\Volume{9809328b-f7ed-11e8-80b5-806e6f6e6963}\”,  
“size”: 53317988352,  
“size\_remaining”: 36704559104,  
“type”: “NTFS”  
}  
]  
}  
],  
“path”: “\\?\scsi#disk&ven\_vmware&prod\_virtual\_disk#5&174a0eaf&0&000000#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}”,  
“physical\_disk”: {  
“allocated\_size”: 53687091200,  
“bus\_type”: “SAS”,  
“can\_pool”: false,  
“cannot\_pool\_reason”: “Insufficient Capacity”,  
“device\_id”: “0”,  
“firmware\_version”: "1.0 ",  
“friendly\_name”: “PhysicalDisk0”,  
“health\_status”: “Healthy”,  
“indication\_enabled”: null,  
“manufacturer”: "VMware ",  
“media\_type”: “UnSpecified”,  
“model”: "Virtual disk ",  
“object\_id”: “{1}\\TCGNY-NE-DRVN2\root/Microsoft/Windows/Storage/Providers\_v2\SPACES\_PhysicalDisk.ObjectId="{98093284-f7ed-11e8-80b5-806e6f6e6963}:PD:{cc8752a3-5b18-e7bf-a2a9-3f2776bd9926}"”,  
“operational\_status”: “OK”,  
“partial”: true,  
“physical\_location”: null,  
“serial\_number”: “6000c2945d2a5f3a9f5d4e73168d86e4”,  
“size”: 53687091200,  
“spindle\_speed”: 4294967295,  
“supported\_usages”: {  
“Count”: 5,  
“value”: [  
“Auto-Select”,  
“Manual-Select”,  
“Hot Spare”,  
“Retired”,  
“Journal”  
]  
},  
“unique\_id”: “6000C2945D2A5F3A9F5D4E73168D86E4”,  
“usage\_type”: “Auto-Select”  
},  
“read\_only”: false,  
“sector\_size”: 512,  
“serial\_number”: “6000c2945d2a5f3a9f5d4e73168d86e4”,  
“size”: 53687091200,  
“system\_disk”: true,  
“unique\_id”: “6000C2945D2A5F3A9F5D4E73168D86E4”  
}  
]  
},  
“changed”: false  
}

Someone know the way?.

Thanks in advance

Federico

---

<div class="post-metadata">

**Author:** ![Sebastian\_Meyer](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@Sebastian\_Meyer](https://forum.ansible.com/u/Sebastian_Meyer)\
**Post date:** [March 19, 2019, 7:05am UTC](https://forum.ansible.com/t/convert-yaml-file-into-jinja/29907/2 "2019-03-19T07:05:42Z")

</div>

You can access ansible\_facts in a jinja2 template like you would in a  
playbook:

{{ ansible\_facts['disks'][0]['size'] }}

- Sebastian
