On Tue, 29 Jun 2021 12:42:21 -0700 (PDT) omoeko <[email protected]> wrote:
> Lastly, to add the gather_facts: no. where do i add this in the ansible > role ? See "Playbook Keywords". The directive gather_facts is available in a play only. https://docs.ansible.com/ansible/latest/reference_appendices/playbooks_keywords.html > ... is there a variable which contains all the unreachable hosts. Is it > possible to have this in a > comma delimmeted list and stored in a variable ? The following solution won't work if you set "gather_facts: no". Yes, there are "Special Variables" https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html Quoting: * ansible_play_hosts_all: List of all the hosts that were targeted by the play. * ansible_play_hosts: List of hosts in the current play run, not limited by the serial. Failed/Unreachable hosts are excluded from this list. For example - hosts: alpha,beta,charlie gather_facts: true tasks: - block: - debug: var: ansible_play_hosts_all - debug: var: ansible_play_hosts - set_fact: down: "{{ ansible_play_hosts_all|difference(ansible_play_hosts) }}" - debug: var: down run_once: true gives when the host alpha is down ansible_play_hosts_all: - alpha - beta - charlie ansible_play_hosts: - beta - charlie down: - alpha -- Vladimir Botka -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/20210630070340.40006581%40gmail.com.
pgpajsELl8L1Y.pgp
Description: OpenPGP digital signature
