I'm trying to copy a file, local, to a remote host using a simple Ansible playbook:
---
- name: Transfer file to remote host device
hosts: remotehost
connection: local
tasks:
- name: Send file to remote host
copy:
src: /home/plc/cert.pfx
dest: /root/certificates
But I'm getting permission denied. What's the User/Password that's being used when trying to send the file to the remote host? Can I specify it?
Error I'm getting as follow:
fatal: [remotehost]: FAILED! => {"failed": true, "msg": "Failed to get information on remote file (/root/certificates): Permission denied"}
Given the destination path is /root/certificates
, you must either:
connect as root
(not recommended), or
use privilege escalation with become: true
.
Your connecting account must be configured to be able to do so — all that is well documented, so learn and apply.
Besides, you have an unnecessary connection: local
in your play definition which prevents from connecting to the target server. Remove it.
Considering that, maybe you should start with Getting Started chapter of Ansible documentation.