Getting changed/failed hosts list from a previous task

74 views
Skip to first unread message

sumith nair

unread,
Apr 24, 2021, 6:37:37 AM4/24/21
to Ansible Project
All,

As part of my playbook, i'd like to know the list of hosts where a certain task executed and changed something or got failed. Since i need to use those hosts in the very next task in same playbook for some other action.

Example: If i've got 10 hosts for a playbook, and below task changed/failed on 5 out of the 10 and skipped other 5, i need to gather those affected 5 hosts into a variable maybe, then use that in next task.

          - name: update file count

            shell: "echo 2 > /home/ec2-user/abcd.txt"

            when:

                    - count.stdout == "1"

            register: update1


Thank you.


sumith nair

unread,
Apr 25, 2021, 12:28:19 AM4/25/21
to Ansible Project
Any sort of lead would be appreciated
Reply all
Reply to author
Forward
0 new messages