[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*

On Tuesday, May 28, 2024 at 11:42:18 AM UTC-4 Dimitri Yioulos wrote:

> 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 foundfatal: [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.
>
> On Tuesday, May 28, 2024 at 11:34:03 AM UTC-4 Dimitri Yioulos wrote:
>
>> 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:
>>
>> *---*
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *- hosts: host1,host2  #- hosts: 
>> busdev-web-dev,busdev-web-qa,busdev-web-prod,bed-deploy1,bed-deploy2,uoj,uojclone2,uojdev,bed-crm-web-qa
>>   
>> gather_facts: false  become: yes    #  vars:    # script_path: <script>  
>> tasks:    - name: Find known hosts      shell: find /root /home -type f 
>> -name known_hosts      register: known      tags:        - known    - name: 
>> Debug known_hosts paths      debug:        msg: "{{ known.stdout }}"      
>> tags:        - known    - name: Set fact with known_hosts paths      
>> set_fact:        known_hosts_paths: "{{ known.stdout_lines }}"      tags:  
>>       - known    - name: Back up known_host files      copy:        src: 
>> "{{ known.stdout }}"        dest: /tmp        remote_src: true        
>> backup: yes        #delegate_to: localhost      tags:        - known*
>>
>> I hope the idea is clear. I want to make backups of users' know_host 
>> files, which I've gleaned with the first play. My attempt not only doesn't 
>> work, but seems messy, regardless. As always, help much appreciated.
>>
>

-- 
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/295182c0-d08e-45ca-913b-53c971c8b08an%40googlegroups.com.

Reply via email to