Testing of ansible-based charms

Charles Butler charles.butler at canonical.com
Wed Aug 13 14:31:26 UTC 2014


Michael,

Great write up. This is the general consensus of the Ansible community,
that Ansible itself is well unit tested - and any tests to be performed
against the play book should be done in a dry run scenario, or via unit
testing frameworks such as Server Spec http://serverspec.org/   or using
amulet.

Coming from a heavy rspec / cucumber based background, this was heresy to
me - but I've since adopted the pattern as Ansible playbooks are pretty
solid so long as you aren't loading them up with crazy shell calls with
wonky syntax.

Just my thoughts on the subject,

Charles


On Wed, Aug 13, 2014 at 3:44 AM, Michael Nelson <
michael.nelson at canonical.com> wrote:

> Hi people,
>
> I saw a ping from last Friday:
>
> 12:21 < jcastro> bloodearnest, noodles775: evan is asking (We're at a
> sprint) on how we test the ansible bits in a charm?
> 12:47 < bloodearnest> jcastro: not easily, other than actually running
> it, which is a downside to using ansible currently
> 12:47 < bloodearnest> jcastro: the 2 things I do do are:
> 12:48 < bloodearnest> 1) use ansible-playbook --syntax-check to check for
> typos
> 12:48 < bloodearnest> 2) unit test any templates standalone
> 12:48 < jcastro> ack, thanks, exactly what we needed to know, thanks.
> 12:49 < bloodearnest> jcastro: we've talked about spending some time
> seeing if we can write something that mocks out ansible at some level
> (it's all py
> thon, after all)
>
> and thought it was worth a followup discussion.
>
> IMO unit-testing of an ansible charm only makes sense in the context
> of unit-testing any logic in your templates/playbooks and or the
> *syntax* of your playbook (as Simon mentioned).
>
> Unit-testing any actual tasks that modify the system is going to
> require lots of mocking, just like it does when unit-testing straight
> python hooks. It'd be better to have the ansible modules unit-tested
> themselves (if they are custom), and focus on integration tests for
> the charm (which can be included in your actual playbook - see the
> google-groups thread below).
>
> All the arguments both ways are exchanged between Michael deHaan
> (ansible) and a few others on this thread:
>
> https://groups.google.com/forum/#!topic/ansible-project/7VhqDDtf6Js
>
> summarised by one of the people asking about testing here:
>
> http://sharknet.us/2013/12/12/test-driven-development-with-ansible/
>
> I've also read about people gating their ansible changes by running
> these tests on travis-ci (or anywhere where you can test against a
> known vm state):
>
> http://renemoser.net/blog/2014/01/01/test-ansible-roles-with-travis-ci/
>
> We'd like to do something similar for the shareable ansible roles that
> we're using for our charms.
>
> If anyone has other ideas or issues, please contribute :)
>
> Cheers,
> Michael
>
> --
> Juju mailing list
> Juju at lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/juju
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/juju/attachments/20140813/d23ebc01/attachment.html>


More information about the Juju mailing list