ansible/ansible — pull request #9767 by whiskybar (2014-12-10 16:57:54+00:00)
Title: added a vars_plugin

I have written and used a vars_plugin which other people might find useful, both as an example as well as a variable plugin for the real world use.

I'm adding a new example plugin which uses python files to add extra variables to the current set of variables. The directory `python_vars` is scanned for python files; only the ones named as the current group are taken into account. Each such file is scanned for the function `run(host)` and its result is merged into the current variable set.

For example, let's assume the current host is in the group `dns`. Then, `python_vars/dns.py` can contain

def run(host):
return {'zones': ['example.com']}

and the variable `zones` will be defined as the variable for the current host.