What this code does is: Get some user input at run time, do some tasks (including creating new hosts) depending on the user input at run time. Then do some other tasks in the newly created hosts. The only confusion I am having is in two lines of the code in which I have added comments. All I want to do access the values stored in register array on one host be accessible in another host using the with_items loop. Just have a look at #Comment1 and #Comment2
I am posting some sample output to simplify things with epcrange=2 and serverrange=2 and the rest of the values are default
TASK: [Checking to see if new IPs were stored] ********************************
ok: [localhost] => {
“new_ips”: {
“changed”: false,
“msg”: “All items completed”,
“results”: [
{
“11.11.4.74”: “{{ 11.11.4.74 }}”, #As we can see new ips are being formulated
“invocation”: {
“module_args”: “var=11.11.4.74”,
“module_name”: “debug”
},
“item”: “74”,
“verbose_always”: true
},
{
“11.11.4.138”: “{{ 11.11.4.138 }}”, #As we can see new Ips are being formulated
“invocation”: {
“module_args”: “var=11.11.4.138”,
“module_name”: “debug”
},
“item”: “138”,
“verbose_always”: true
}
]
}
}
TASK: [Display the contents of config_file after modification] ****************
ok: [vm1] => {
“my_content.stdout_lines”: [
“{”,
""ServerIP" : "hostvars.localhost.new_ips.stdout_lines" ", #Only this line in the file is of use to us (w.r.t the code)
""ServerIPRange" : "128" ",
“"Protocol" : "UDP",”,
“"PayloadSize" : "22",”,
“"addGtpTunnel" : "yes",”,
“"ppsLimit" : "2000000",”,
“"testRuntime" : "120",”,
“}”
]
}
ok: [vm2] => {
“my_content.stdout_lines”: [
“{”,
""ServerIP" : "hostvars.localhost.new_ips.stdout_lines" ", #nly this line in the file is of use to us (w.r.t the code)
""ServerIPRange" : "2" ",
“"Protocol" : "UDP",”,
“"PayloadSize" : "22",”,
“"addGtpTunnel" : "yes",”,
“"ppsLimit" : "2000000",”,
“"testRuntime" : "120",”,
“}”
]
}
Short Summary. I defined a register array named new IPs in localhost and now I want to access each entry of that register iteratively using {{items}} or whatever method. I can’t figure out how?