Please paste the code WITHOUT any formatting. Font should be any single-space so that spacing is correct.
--
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 post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/babac43c-57f2-4091-b2ee-8fdc32291378%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
- name: output
debug:
var: svc.results.[item].exists
with_sequence: count='{{nb_of_agents}}'
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.
- name: output debug: var: qb_svc - name: output debug: var: qb_svc.results[item].exists with_sequence: count='{{nb_of_agents}}'
task path: /ansible/scripts/playbooks/qb-agents-fw-multiple.yml:16ok: [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:20ok: [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:25fatal: [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
qb_svc.results[item|int].exists and see if that works?
- name: output debug: var: qb_svc.results[item|int].exists with_sequence: start=0 end='{{nb_of_agents - 1 |int}}'