Hello Everyone,
Greetings!
I am working to get failed hosts from 'rescue' section into a CSV file.
When i run task for *'inventory_hostname*' from *'rescue'* section:
rescue:
> - name: inventory_host name list debug
> debug:
> msg: "{{ inventory_hostname }}"
> Output:
> TASK [inventory_host name list debug]
> *******************************************************************************************************************************************************************************************************
> ok: [bogus1] => {}
>
> MSG:
>
> bogus1
> ok: [bogus2] => {}
>
> MSG:
>
> bogus2
>
> *when i tried to append data to a list. *
> - set_fact:
> failed_list: "{{ failed_list + [ansible_host] }}"
> - name: failed_list debug
> debug: var=failed_list
>
Output:
TASK [set_fact]
*****************************************************************************************************************************************************************************************************************************
ok: [bogus1]
ok: [bogus2]
TASK [failed_list debug]
********************************************************************************************************************************************************************************************************************
ok: [bogus1] => {
"failed_list": [
"bogus1"
]
}
ok: [bogus2] => {
"failed_list": [
"bogus2"
]
}
Here bogus1, bogus2 host names are failed in 'resce' section.
We have multiple hosts in our environment. While running playbook we have
to capture failed hostname into a file as mentioned below:
*failed_hosts.csv:*
*number of failed hots: 2*
*hostname:*
*bogus1*
*bogus2*
Thank you for your help.
--
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/CANGEjuXCUuCkps8CU9oWnh3XHN7jo6OJnGJQOCQRvay9w1rg2w%40mail.gmail.com.