Module composition?

Hello all.

I'm looking into writing some higher-level modules that would allow
my group to do something like the following in a playbook:

  tasks:
    - name: Install FooApp
      action: foo vers=4.4 root=/srv/foo

Where the foo module would combine several calls to a package
manager (using the apt, yum, or git modules), calling some custom
scripts (using command), and installing a default config and an init
script (the file or template modules), and with predetermined
parameters. (Obviously these would not be intended for
redistribution.)

What's the best way to go about this? My first thought was to use
the ansible.runner.Runner class, but that looks like it manages the
connection itself, which I don't want -- I want to do it all in the
same connection.

Am I missing something obvious? Or perhaps approaching this the
wrong way? I wanted something a little more self-contained and
abstracted than include files, if only because using include doesn't
honor ANSIBLE_LIBRARY (I want to store and manage these separately
from the plabooks).

Thanks for any ideas.

Hello all.

I'm looking into writing some higher-level modules that would allow
my group to do something like the following in a playbook:

tasks:
- name: Install FooApp
action: foo vers=4.4 root=/srv/foo

ok...

Where the foo module would combine several calls to a package
manager (using the apt, yum, or git modules), calling some custom
scripts (using command), and installing a default config and an init
script (the file or template modules), and with predetermined
parameters. (Obviously these would not be intended for
redistribution.)

What's the best way to go about this? My first thought was to use
the ansible.runner.Runner class, but that looks like it manages the
connection itself, which I don't want -- I want to do it all in the
same connection.

modules are executed on the remote host without round trips to the server, and the module cannot make requests for the server to do other things except in the case of 'daisy chained modules', which only let you get to pick one more module to run -- it's get_url allows you to set the owner of the file. Basically modules are expected to be "done" once executed on the remote and entirely self contained.

However, that's not a bad thing. What you are speaking of is actually, whether it may not be obvious or not, a playbook!

Take a look at what Lorin wrote recently for deploying OpenStack or what Mark wrote for deploying a LAMP server. Apps don't get too much more complicated than this, and since in 0.6 and later, playbooks can include other playbooks at top level, there are a lot of options for how you organize.

I'd start by looking at those examples here:

https://github.com/ansible/ansible-resources

Thanks for the quick answer. I'll take a look at these now.

* Michael DeHaan <michael.dehaan at gmail.com> [2012/08/10 21:51]: