# Playbook datastructure when using the Python API

**URL:** <https://forum.ansible.com/t/playbook-datastructure-when-using-the-python-api/22902>\
**Category:** Ansible Developer\
**Created:** [October 27, 2016, 1:26pm UTC](https://forum.ansible.com/t/playbook-datastructure-when-using-the-python-api/22902 "2016-10-27T13:26:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Francesco\_Albanese](https://avatars.discourse-cdn.com/v4/letter/f/7feea3/32.png) [@Francesco\_Albanese](https://forum.ansible.com/u/Francesco_Albanese)\
**Post date:** [October 27, 2016, 1:26pm UTC](https://forum.ansible.com/t/playbook-datastructure-when-using-the-python-api/22902/1 "2016-10-27T13:26:46Z")

</div>

Hello,

In order to harmonize several in-house operations, I wrote some self-contained Python command line tools built upon the Ansible core.  
As it is not desirable to be dependent on several external files, my code embeds both the the host file and the tasks to execute.  
For the latter I used as starting point the [example](http://docs.ansible.com/ansible/dev_guide/developing_api.html#python-api-2-0) of online manual. However, more complex constructs are missing: e.g. I do not know  
how to express conditionals statements like “when” and “block”. Generally speaking, is it possible to have a better understanding of the  
playbook datastructure in the Python realm ?

Thanks in advance
