From ffdca762fa0801f68f76301830b754390219c14d Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Tue, 21 Aug 2012 20:46:11 -0400 Subject: [PATCH] Add template example so I don't have to remember how it works --- examples/playbooks/templates/hostvars.j2 | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 examples/playbooks/templates/hostvars.j2 diff --git a/examples/playbooks/templates/hostvars.j2 b/examples/playbooks/templates/hostvars.j2 new file mode 100644 index 00000000000..ca8f51482ad --- /dev/null +++ b/examples/playbooks/templates/hostvars.j2 @@ -0,0 +1,7 @@ +# example of how to get the ipaddress of every machine in the webservers group +# for use in a template + +{% for host in groups['webservers'] %} + HOST: {{ host }} IP: {{ hostvars[host]['ansible_all_ipv4_addresses'][0] }} +{% endfor %} +