Need to know where we need to write the code for below thing -

I know it is stupid question, but how can I use the beow code in my playbook . Do we need to use any command or shell for this ?

{% for host in groups[‘app_servers’] %}
{{ hostvars[host][‘ansible_eth0’][‘ipv4’][‘address’] }}
{% endfor %}

put it in a template and use template module? hard to answer with the
context given.