I am trying to get some result from the hostvars , but fails.
playbook:
- debug:
msg: "{{hostvars[item]['a']}}"
run_once: true
delegate_to: localhost
with_items: "{{ groups['all'] }}"
results:
ok: [ansible8] => (item=ansible8) => {
"msg": [
{
"ansible_job_id": "921062922128.33800",
"attempts": 1,
"end": "2021-09-16 05:39:47.335977",
blah blah
"start": "2021-09-16 05:39:46.323621"
}
]
}
ok: [ansible8] => (item=ansible7) => {
"msg": [
{
"ansible_job_id": "688007320452.57867",
"attempts": 1,
"end": "2021-04-03 22:12:40.249637",
blah blah
"start": "2021-04-03 22:12:39.241665"
}
]
}
Now, i would like to get the a.start and a.end, so my playbook like this:
- debug:
msg: "{{hostvars[item]['a']['start']}}"
run_once: true
delegate_to: localhost
with_items: "{{ groups['all'] }}"
But apparently it didn't work, and got the error msg
"The task includes an option with an undefined variable. The error was: 'list object' has no attribute 'start'
Appreciate any help, thanks