Ansible copy files from remote host to network share

12 views
Skip to first unread message

Andy Magana

unread,
May 17, 2019, 6:10:46 PM5/17/19
to Ansible Project
I am trying to get a playbook to run the open-scap scanner but I need those results on the remote host to be copied over to a network share I am trying something like this but getting "permission denied"

- name: find it
  find
:
     path
: /tmp/
     patterns
: '*_oscap_results.html,*_oscap_arf.xml'
 
register: oscap_results
 

- name: copy it
  fetch
:
      src
: "{{ item.path }}"
      dest
: /mnt/SCAP/

Thanks for any tips.

Andy Magana
Oklahoma City.

Knut Karevoll

unread,
May 18, 2019, 2:34:49 PM5/18/19
to Ansible Project
I am assuming you cut out a line too early and that you are looping over the oscap_resultfor the last line there. You also do not mention where and how the network share is mounted. The fetch module copies the file from the remote to the local node. So it is equivilant to running "scp {{ansible_user}}@{{ansible_ssh_address}}:/tmp/*_oscap_results.html /mnt/SCAP/{{ansible_hostname}}/tmp/". So make sure that /mnt/SCAP/ is mounted on the node you are running ansible from and that you have the permission to create files and directories there. You might also look at the "copy" module with "remote_src: True" if the network share is mounted on the remote node.
Reply all
Reply to author
Forward
0 new messages