On Fri, 23 Oct 2020 at 09:54, Sobhan Anavarapu <sobhan.anavar...@gmail.com> wrote: > > Yes template module will loop. But i seeking to create multiple files with > there respective output
No the template module will not loop. But it should. What i meant to say is that YOU should change the code and ADD a loop statement. But first inspect the "configout" data structure to see what you need to loop over exactly. If it isn't obvious, each task that needs to loop over something needs a loop statement. I'm saying because you have the loop statement separately. On another note, there is no task called "value_command" - is this some internally developed module? The playbook is wrongly indented in other places - maybe a result of poor copy/pasting. > But receiving below error > fatal: [localhost]: FAILED! => { > "msg": "The task includes an option with an undefined variable. The error > was: 'item' is undefined\n\nThe error appears to be in '/root/check.yml': > line 99, column 5, but may\nbe elsewhere in the file depending on the exact > syntax problem.\n\nThe offending line appears to be:\n\n\n - name: Copying > the date to file\n ^ here\n" > } > > On Friday, October 23, 2020 at 1:20:37 PM UTC+5:30 dick....@geant.org wrote: >> >> The template task should loop over configout >> >> >> >> On Fri, 23 Oct 2020 at 09:36, Sobhan Anavarapu <sobhan.a...@gmail.com> wrote: >>> >>> Hi All, >>> I am seeking for your help if I can create files in the controller node >>> with the output we generate against the multiple IP's >>> Eg: If I am passing 2 IP's with vars_prompt. In copy module it should >>> create 2 different file with IP's we passed and save the data. >>> >>> --- >>> - name: check >>> hosts: localhost >>> gather_facts: False >>> >>> vars_prompt: >>> - name: ip_addr >>> prompt: Please enter the switch name >>> private: no >>> >>> tasks: >>> - name: checking the switchshow >>> value_command: >>> switch_address: {{ item }} >>> command_set: >>> - command: portshow 1 >>> >>> with_items: "{{ ip_addr.split(' ') }}" >>> register: configout >>> >>> - name: Copying the date to file >>> template: >>> src: report.j2 >>> dest: "/root/file-{{ item }}.log" >>> become: true >>> delegate_to: localhost >>> >>> -- >>> 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 ansible-proje...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/ansible-project/d2eb4234-f6ba-4269-85e6-cb414f5ea4b1n%40googlegroups.com. >> >> -- >> Sent from a mobile device - please excuse the brevity, spelling and >> punctuation. > > -- > 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 ansible-project+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/8176a6dd-24c5-42cc-abec-8080eaab59c3n%40googlegroups.com. -- Dick Visser Trust & Identity Service Operations Manager GÉANT -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAL8fbwN%2BebypzuCP7e%2Bb43yaXNAizmvmsAwBvzX%2BLpGatix_pQ%40mail.gmail.com.