I think this answer might give you a pointer in the right direction: https://stackoverflow.com/a/52237675
It should work, but there could be a better/simpler way to do this. Do you control the generation of the files that provide your source variables? What's the *actual *problem you need to solve? (Obviously dynamically generating and presumably running some SQL but can you step back a level or two and describe the actual goal?) On Wed, 14 Jun 2023 at 12:07, [email protected] <[email protected]> wrote: > Hi , > > > I’m using the template module that takes a J2 template and update the > relevant fields. > > My problem is When I want to create a file per file input should be used > as variable – I’m actually need to understand how to loop file that should > be used as var files > > > *My J2 file* > > select * from {{ item.id}} where {{ item.color}} > > > > *My input files* > > *File-1.yml :* > > Id: 1 > color: blue > > > > *File-2**.yml** :* > > Id: 2 > color: red > > > > *My Playbook – that is not working. * > > > > - hosts: localhost > become: true > gather_facts: yes > tasks: > - name: > template: > src: /opt/input.sql.j2 > dest: /opt//{{item.id}}.sql > with_items: > - file-1.yaml > > - file-2.yaml > > > > > > *The output files I wish to have * > > 1.sql > > select * from 1 where blue > > > > 2.sql > > select * from 2 where red > > -- > 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 view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/50d4e830-9330-43be-95dc-68795a311d9an%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/50d4e830-9330-43be-95dc-68795a311d9an%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAKtKohRFy9yojZ5X9v9ja0V7WVUYU%2BKP5FuYkA1ZxXRd1KRSqQ%40mail.gmail.com.
