Copy Module with host name in file: dest: "/root/file <hostname>

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.

The template task should loop over configout

Yes template module will loop. But i seeking to create multiple files with there respective output

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”
}

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.