What I want in ansible:
Essentially, it is a simple way to let me port a bunch of puppet
modules directly to ansible.
right now I can include tasks - which is great
and I can include handlers - which is great
Ideally, though, I want to just include a single line and 'boom' that
playbook now does that new stuff. I want to deal with a set of tasks
and handlers and files/templates and variables, potentially, as a blob
that is 'finished'. So I can work on the blob, get it right, and not
have to modify all my other playbooks to fit it in.
In a lot of cases the porting of these modules is easy enough with
just included tasks - but the moment I need to do any special
variables or handlers that doesn't work w/o touching ALL of my
playbooks to include specific vars_files or to include handlers.
So what I think I want is an included 'thing' that inherits from the
current play. For the moment I've been calling it a playlet. It has
tasks, variables, handlers all of its own which are local to that
playlet in scope. It inherits the variables, handlers, and host-list
from the play it is included in and the variables/vars_files that it
includes are overridden exactly like ones in a playbook - meaning
group_vars, host_vars and extra_vars override them. (by treating vars
like that it would mean I could have sensible defaults in vars in a
task list w/o having to do any weird checks elsehwhere)
basic structure of where a playlet fits:
playbook
- play1
- playlet1
- playlet2
- play2
- playlet3
- playlet1
Perhaps a playlet would have a directory structure something like
playlet_name/
vars/vars.yml
files/myfile.conf
myfile2.conf.j2
handlers/handlers.yml
playlet.yml
so an example play inclusion would be like:
- name: my play with playlets
hosts: myhosts
playlets:
- path/to/playlet_name
- path/to/playet_name_2
tasks:
- name: my task
action: stuff which I do
Questions:
1. do playlets run before or after tasks in any given play?
2. should there be some other way ordering them?
3. is a playlet just a short hand for:
- run this playbook - but override hosts with whatever this play
has and force these vars/handlers into it? Is it bad to have this kind
of short hand? Should we just allow a way to include playbooks like
this and stuff a bunch of vars into them?
4. can playlets include other playlets? (I'm inclined to say NO
but....)
5. what does running a playlet do to cwd for looking up files,
etc?
6. what does a playlet do with --tags?
7. what does a playlet do with --step?
I hope this helps flesh out what I was looking for here and explain how
I would like to use it. I've been looking at the playbook parsing code
to see how to fit this in w/the smallest amount of pain and it seems
like creating a new play and preloading the values from the existing
play would work - but I'm not sure if this is a good way of going about
it or if I should be looking at some sort of plugin that this would
work as.
Thanks,
-sv