On Tue, 13 Jan 2015, Tom Bamford wrote: > If you want greater control of when your common tasks get executed, I would > be more inclined to use rules and have verbose playbooks with the execution > order explicitly specified. > > Perhaps if you could give a better idea of what your common tasks are and > the context in which you want to run them?
The common tasks involve configuring containers (it doesn't matter what kind of container; that's liable to change) then installing software elements into it and registering services. However, to pick a simpler, concrete example, let's say I've a playbook that needs to install a package, foo. I want to use this playbook against both apt and yum-based systems; and possibly against systems that use other packaging mechanisms in the future. [[[ - apt: name=foo when: system == 'apt' - yum: name=foo when: system == 'yum' ]]] Do I really need to repeat this logic everywhere I might want to install a package? What I'm after is the ability to write: - package: name=foo and centralise the code that picks a concrete implementation. Is there already a way to express this simple kind of abstraction in ansible? I know I can do something like - include: ../../common/tasks/install-package.yml name=foo but writing this is klunky and error-prone; I'm just wondering if there are neater ways to achieve this - so that playbooks can separate the "what" and the "how". Cheers, jan -- [email protected] http://ioctl.org/jan/ Short, dark, ugly: pick any three I shave with Occam's Razor.
