# (developers) First peek at the ansible-commander data layer

**URL:** <https://forum.ansible.com/t/developers-first-peek-at-the-ansible-commander-data-layer/11875>\
**Category:** Ansible Project\
**Created:** [September 8, 2012, 5:03pm UTC](https://forum.ansible.com/t/developers-first-peek-at-the-ansible-commander-data-layer/11875 "2012-09-08T17:03:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [September 8, 2012, 5:03pm UTC](https://forum.ansible.com/t/developers-first-peek-at-the-ansible-commander-data-layer/11875/1 "2012-09-08T17:03:24Z")

</div>

As I mentioned earlier, I'm going to keep everyone updated as  
ansible-commander evolves. What you now see in the repo  
is the result of only a few hours of hacking.

As it turns out, as is always the case, that the latest shiny toys you  
want to use on CentOS 6 are never there. In this case, the psycopg2  
extensions for hstore were MIA, so I decided to not use hstore --  
which also makes things easier to set up. Ah well. I don't think we  
need it, and it will lower the complexity of the SQL anyway.

&nbsp;&nbsp;&nbsp;&nbsp;[https://github.com/ansible/ansible-commander/blob/master/acom/data.py](https://github.com/ansible/ansible-commander/blob/master/acom/data.py)

This is a really rough sketch of a NewSql-style data layer in  
Postgres, as you can see, adding a new type of object  
is going to be pretty simple. It's following the Reddit model of only  
having two tables, so we don't have to worry about migrations.

There's more to add like a function to check the data types and  
general sanity, but you can see the basics here.

This is enough to start plumbing up the basics of the REST API.

One of the things the REST API is going to have to do is keep track of  
some cached data, so when we add a group to a parent group it will  
keep up all the kid hosts and grandkid groups, etc -- to make things  
nice and fast. The API will not allow editing these, but will be  
updated behind the scenes when edits are made. This is still left to  
be done.

So, the next step is to flesh out the REST API for groups to the point  
where we can exercise it.

Users will work just like groups. The app will automatically insert  
a default user if there are none, and you'll be able to edit your  
password using the REST API. API users will never need to know the  
database password, but there is one, and the Ansible app can only  
access the Ansible database.

--Michael

---

<div class="post-metadata">

**Author:** ![Stephen\_John\_Smoogen](https://avatars.discourse-cdn.com/v4/letter/s/ad7895/32.png) [@Stephen\_John\_Smoogen](https://forum.ansible.com/u/Stephen_John_Smoogen)\
**Post date:** [September 8, 2012, 6:28pm UTC](https://forum.ansible.com/t/developers-first-peek-at-the-ansible-commander-data-layer/11875/2 "2012-09-08T18:28:01Z")

</div>

I noticed that you were earlier dealing with Centos 5 issues with the  
ansible layer.. will you be needing to do so for the commander too?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [September 8, 2012, 6:30pm UTC](https://forum.ansible.com/t/developers-first-peek-at-the-ansible-commander-data-layer/11875/3 "2012-09-08T18:30:28Z")

</div>

> I noticed that you were earlier dealing with Centos 5 issues with the  
> ansible layer.. will you be needing to do so for the commander too?

Ansible-commander will require python 2.6, Flask, and psycopg2.  
Provided folks install the appropriate libraries, it should work, but  
it's not something I'm going to go out of my way to support.

(Ansible itself similarly requires Python 2.6 on the central machine,  
but supports 2.4 nodes)

--Michael

---

<div class="post-metadata">

**Author:** ![Marco\_Vito\_Moscarito](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@Marco\_Vito\_Moscarito](https://forum.ansible.com/u/Marco_Vito_Moscarito)\
**Post date:** [September 8, 2012, 9:10pm UTC](https://forum.ansible.com/t/developers-first-peek-at-the-ansible-commander-data-layer/11875/4 "2012-09-08T21:10:31Z")

</div>

Great work Michael!

Maybe remove Postgree dependencies to a light weight DB (sqlite?) can  
make ansible-commander more "ready-to-go" and self-contained, but make  
data directly accessible from other (non-python) application.

Bye  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Marco

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [September 8, 2012, 11:16pm UTC](https://forum.ansible.com/t/developers-first-peek-at-the-ansible-commander-data-layer/11875/5 "2012-09-08T23:16:51Z")

</div>

Just PostgreSQL for now. Can think about that much later once things level out.

Groups have unit tests for basic things now, I have to add the logic  
to save their cached relations, and then we can start wiring them up  
into REST.

Representing treeishness in NoSQLish SQL is a good way to fry your  
brain. Though thankfully also somewhat fun in retrospect.

--Michael
