Thank you Jordan Actually, I also tried without the "." as you suggested and it didn't work Code: - name: output debug: var: qb_svc - name: output debug: var: qb_svc.results[item].exists with_sequence: count='{{nb_of_agents}}'
Here is my output with your suggestion: task path: /ansible/scripts/playbooks/qb-agents-fw-multiple.yml:16 ok: [hasgappqba1102.DOMAIN] => { * "qb_svc": {* "changed": false, "msg": "All items completed", * "results": [* { "_ansible_ignore_errors": null, "_ansible_item_result": true, "_ansible_no_log": false, "_ansible_parsed": true, "changed": false, * "exists": false,* "failed": false, "item": "1" }, { "_ansible_ignore_errors": null, "_ansible_item_result": true, "_ansible_no_log": false, "_ansible_parsed": true, "changed": false, * "exists": false,* "failed": false, "item": "2" } ] } } TASK [output] ************************************************************************************************************************************************************************************************************************************************************************************** task path: /ansible/scripts/playbooks/qb-agents-fw-multiple.yml:20 ok: [hasgappqba1102.DOMAIN] => (item=None) => { "qb_svc.results[item].exists": "VARIABLE IS NOT DEFINED!: 'list object' has no attribute u'1'" } ok: [hasgappqba1102.DOMAIN] => (item=None) => { "qb_svc.results[item].exists": "VARIABLE IS NOT DEFINED!: 'list object' has no attribute u'2'" } TASK [install Agent '{{ item }}'] ****************************************************************************************************************************************************************************************************************************************************************** task path: /ansible/scripts/playbooks/qb-agents-fw-multiple.yml:25 fatal: [hasgappqba1102.DOMAIN]: FAILED! => { "msg": "The conditional check 'qb_svc.results[item].exists' failed. The error was: error while evaluating conditional (qb_svc.results[item].exists): 'list object' has no attribute u'1'\n\nThe error appears to have been in '/ansible/scripts/playbooks/qb-agents-fw-multiple.yml': line 25, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: install Agent '{{ item }}'\n ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes. Always quote template expression brackets when they\nstart a value. For instance:\n\n with_items:\n - {{ foo }}\n\nShould be written as:\n\n with_items:\n - \"{{ foo }}\"\n" } to retry, use: --limit @/ansible/scripts/playbooks/qb-agents-fw-multiple.retry Thank you! On Tuesday, May 22, 2018 at 8:04:06 AM UTC+3, Jordan Borean wrote: > > You can't normally run in parallel with a loop, they are run sequentially. > You can hack around it by running with async and poll 0 and then poll that > status but it isn't a perfect "run all items in list in parallel" that you > are looking for. > > Your debug output > > - name: output > debug: > var: svc.results.[item].exists > with_sequence: count='{{nb_of_agents}}' > > Won't work as you are trying to get key 0, 1, 2, 3, etc of the svc.results > var when it is actually a list. You want something like 'svc.results[item > ].exists' instead. What this does is get's the list entry of item, bare > in mind that lists are a 0 based index, so the first entry is 0, 2nd is 1 > and so on. You might have to do something like 'svc.results[item - > 1].exists' if you want to match up the entry to your agent index starting > at 1. > > I haven't used with_sequence a lot so can't tell if that syntax is ok, > apart from that what you have seems ok at a brief glance but having the > output from a run that failed would help us narrow down your issue. > > Thanks > > Jordan > -- 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 post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/de65d7db-4d31-43ef-ac9e-11e699e550eb%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.