Parameterized includes / aka definitions / aka sharing between playbooks with variables

I’ve updated examples/playbook.yml showing how an include statement can take parameters.

This works for both task includes and “notifier” includes.

This allows for what I said earlier – you can define an application or unit of work using a .yml file and install it 3 or 4 times in the same playbook with different parameters, or share a template between patterns and playbooks while feeding it different variables to customize it.

Such as:

tasks:

  • include homedir.yml name=timmy
  • include homedir.yml name=bob

ETC

Also note that TECHNICALLY… though I wouldn’t encourage it, since includes are Jinja2 templates
you could get as crazy as that as you would want. I’ll leave that up for others to play with as all I
wanted was basic variable substitution. And we’ve got that. Score.

It’s probably time to start writing some more real world examples for the playbook. Once we have the yum plugin I’m going to write my deployment example, but we could probably use quite a few more (wink, wink, nudge nudge)…
I think it syncs in a lot better with examples than trying to explain in words.

Fire away!

–Michael