I'm quite sure this has been asked before. But I can't find any discussions
on it and the current functionality seems a bit crippled. Please let me
know if I am missing something.
I would love to be able to define a role and use it from various other
roles as if it was a module. For example, many of my roles need to create
upstart scripts (after installing a few other things and before starting
the service). I would love to simply include an upstart role that takes a
few variables and creates the needed template(s). This would allow me to
avoid having an upstart template in all my roles that need to create one.
Here is what I understand to be my current set of options for doing
something like this and why I don't think it's quite as clean:
*Create the upstart role and define it as a dependency*
This mostly work. But I don't always want the roles in question to run
first. In the example of the upstart role, I would prefer running it after
all the various packages have been installed. Another issue with this one
is the fact that I cannot use loops like when *include* is used. It doesn't
allow me to have a variable passed in as the list of dependencies. For
example, if a role needs to define a variable number of upstart scripts, I
can't have a variable number of dependencies (I don't think).
*Place the logic in a task outside of roles and include that*
This doesn't allow me to have a reusable role for all upstart related
logic. I lose templates, defaults, files, etc. I need to know exactly where
this loose task file is and set up all the related files manually.
I was hoping to be able to do something along these lines:
--- #in some role
# some tasks here
- include: upstart
vars:
name: '{{ item.name }}'
command: '{{ item.command }}'
root: /path/to/app
instance_count: '{{ item.instance_count }}'
with_items: '{{ my_services }}'
# some other tasks here
The example is kind of bare but I hope it makes sense. I can expand on it
if needed.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/7abf1e10-15c6-4f72-a866-911c7b574dc0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.