The use case is to run a specific task once over all hosts only when at 
least one host failed the previous task.

It could be something like:

        - name: How to list a subelement from hostvars for all 
ansible_play_hosts
          gather_facts: True
          hosts: all
          strategy: debug
          tasks:
                - name: Run first task
                  include_tasks: "task.yml"
                  register: return_task
                  ignore_errors: yes

                - name: Run second task when first task has failed on at 
least one playing host
                  debug:
                        msg: "first task has failed on at least one of: {{ 
ansible_play_hosts }}"
                  when: ansible_play_hosts | map('extract', hostvars, 
'return_task.failed') | list is any

The conditional makes the last task fail with:
'ansible.vars.hostvars.HostVarsVars object' has no attribute 
'return_task.failed'

Any suggestion to correct the conditional?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7a643870-3cd5-49ad-b699-5ea83d1ee4ben%40googlegroups.com.

Reply via email to