Loop in file template — Ansible module template — Generate hosts file
How to use for loop in Ansible module template to generate/etc/myhosts file with IP address, hostname, and short name from Ansible inventory. Ansible Playbook, Jinja2 template, and with Magic Variables included.
5 min readNov 24, 2021