# Debug output as copy source

**URL:** <https://forum.ansible.com/t/debug-output-as-copy-source/38798>\
**Category:** Ansible Project\
**Created:** [May 28, 2024, 3:34pm UTC](https://forum.ansible.com/t/debug-output-as-copy-source/38798 "2024-05-28T15:34:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [May 28, 2024, 3:34pm UTC](https://forum.ansible.com/t/debug-output-as-copy-source/38798/1 "2024-05-28T15:34:03Z")

</div>

Hi, all.

I want to use the output of debug as the source to then create backups of that source (eek, I understand that; hope everyone else does). Here’s the playbook relevant parts:

---

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [May 28, 2024, 3:42pm UTC](https://forum.ansible.com/t/debug-output-as-copy-source/38798/2 "2024-05-28T15:42:17Z")

</div>

Btw, the error output from the above is:

**fatal: [bed-test-9-dy2]: FAILED! =\> changed=false**  
**msg: |-**  
**Source /root/.ssh/known\_hosts**  
**/home/user1/.ssh/known\_hosts**  
**/home/user2/.ssh/known\_hosts**  
**/home/user3/.ssh/known\_hosts**  
**/home/user4/.ssh/known\_hosts not found**

**fatal: [bed-test-9-dy5]: FAILED! =\> changed=false**  
**msg: |-**  
**Source /root/.ssh/known\_hosts**  
**/home/ user1/.ssh/known\_hosts**  
**/home/user2/.ssh/known\_hosts**  
**/home/user3/.ssh/known\_hosts not found**

Those files do exist.

---

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [May 28, 2024, 4:35pm UTC](https://forum.ansible.com/t/debug-output-as-copy-source/38798/3 "2024-05-28T16:35:38Z")

</div>

[SOLVED] Answered my own question, and, to simple really. Hope it helps someone:

**- name: Backup all known\_hosts files**  
**shell: cp -p {{ item }} {{ item }}.bak**  
**loop: ‘{{ known.stdout\_lines }}’**  
**tags:**  
**- known**
