ansible/ansible — pull request #1708 by andronat (2012-11-30 17:30:54+00:00)
Title: Template testing

Hello,

this is a first attempt to add template module to work with ansible CLI. I am trying to make the module work as a debug tool and print out the template to stdout. I managed to take the variables from group_vars and host_vars. I have a lot of questions though on how to make it right.

1) I copy-pasted the code that reads the variables from lib/ansible/playbook/play.py. I am thinking that maybe the inventory class should contain this code and we can access all variables for each host like:

inventory.get_group_vars(host)
inventory.get_host_vars(host)

2) I am thinking that the template module should act as both as a debug tool and as action (like inside the playbook). In this code the module will work only as a debug tool, if you call it like :

ansible -m template -a src=...

(specify only src)

If you add dest to your command it will act as a playbook action (so the file will be copied to the host and not stdout).

I believe that this can be a general idea for other modules too. So we can provide to the users a way to inspect their actions before they actually deploy them.