Hello,

I have a scenario where I have the vars/main.yml

/vars/main.yml
---
 a_port:
  - Ethernet1
  - Ethernet2

device_info:
 - { host: toDeviceA, ip_address: 192.168.1.1 }
 - { host: toDeviceB, ip_address: 192.168.2.1 }

I want to be able to populate a template file 

/templates/test.j2

interface {{% a_port %}}
ip address {{% device_info %}}

The end output will be something like below:

interface ethernet1
 ip address 192.168.1.1
interface ethernet2
 ip address 192.168.2.1

in the tasks/main.yml I have tried the following and other types but can't 
get a good result

---

- name: G

  template: src=test.j2 dest=/switch-1.txt

  with_items: a_port

  with_items: device_info

I'd like some advice on how best to structure the loop and where best 
whether in the /tasks or /template/.j2 file.

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1e8788b2-e330-4c02-9262-ab9c246ea31d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to