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

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.

    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

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?

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

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
       Marco

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