Migrating the python-django charm to Ansible

Patrick Hetu patrick.hetu at gmail.com
Wed Nov 5 17:22:10 UTC 2014


Since the last UDS, I'm trying to make the python-django charm evolve
to use Ansible for is various tasks instead of using pure Python scripts.

My previous attempt:

  lp:~patrick-hetu/charms/precise/python-django/ansible

had some problems so I decided to restart from scratch here (work in
progress):

  lp:~patrick-hetu/charms/precise/python-django/ansible_reboot

Based on the following observations.

Use roles that are not specific to Juju
---------------------------------------

If you look at an Ansible role you will probably found a file
defaults/main.yml or vars/main.yml. For me it was stunning how close
those are to a charm configuration file.

So why not grab this opportunity to use the same file
(minus the charm name at the top [1]) with both Juju and Ansible
and make Juju use the same roles that Ansible community are using by
introducing
shims in the charm playbook.

[1] Using a configuration file without that charm name at the top
was working in the past but now doesn't. Maybe this could be
re-enable without to much negative impact.

Couple the playbook with Juju with a shim
-----------------------------------------

To get the playbook to work with an external role we could use
a shim file that translate Juju's dynamic configuration
and relation data to roles variables.

I was thinking using a shim imported in the pre_tasks section of
the charm's playbook that runs on all tags.
(see: https://github.com/ansible/ansible/issues/3157)

The shim would do things like:

* Translating Juju variable to role variable
* Sanitize variable like: unit_name, relation_name, etc
* Ensure backward compatiblity

Then using tags to dispatch based on the current relation
to the corresponding roles.

Build role for re-usability
---------------------------

This have the potential to solve the problem of repetition of some
high level tasks in other charm.
Like adding ppa, fetching source code, adding ssl certificate,
configuring backup, etc

A little bit like what charmhelper is doing right now.

I might not be clear so don't be afraid to ask clarification.
I'm looking forward to receive your feedbacks

Patrick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/juju/attachments/20141105/63ef3aba/attachment.html>


More information about the Juju mailing list