# Print (debug: msg) unreachable hosts

**URL:** <https://forum.ansible.com/t/print-debug-msg-unreachable-hosts/25421>\
**Category:** Ansible Project\
**Created:** [September 6, 2017, 6:15pm UTC](https://forum.ansible.com/t/print-debug-msg-unreachable-hosts/25421 "2017-09-06T18:15:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Darko\_Milodanovic](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@Darko\_Milodanovic](https://forum.ansible.com/u/Darko_Milodanovic)\
**Post date:** [September 6, 2017, 6:15pm UTC](https://forum.ansible.com/t/print-debug-msg-unreachable-hosts/25421/1 "2017-09-06T18:15:32Z")

</div>

Is there a way to register unreachable hosts and print them afterwards using debug/msg??

- name: check if the node is UP  
shell: echo {{inventory\_hostname}}  
register: ping\_test

- name: show debug  
debug:  
var: ping\_test

This is basically what i did , but it will not show unreachable hosts, only those that have succeeded .

Further i would like to do something like this:

- name: Append to file if the node is down  
lineinfile:  
dest: “/tmp/hdd\_check.log”  
line: “{{ inventory\_hostname }},DOWN”  
insertafter: EOF  
when: ping\_test|failed  
ignore\_errors: true

But i cannot because the host is not registered when it’s unreachable.

Please help 🙂

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [September 6, 2017, 7:46pm UTC](https://forum.ansible.com/t/print-debug-msg-unreachable-hosts/25421/2 "2017-09-06T19:46:22Z")

</div>

Yes.

- name: Unreatchable hosts  
&nbsp;&nbsp;debug: msg="Host unreatchable - {{ item }}"  
&nbsp;&nbsp;with\_items: "{{ ansible\_play\_hosts\_all | difference(ansible\_play\_hosts) }}"
