我正在尝试使用简单的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
但我得到了许可被拒绝 . 尝试将文件发送到远程主机时,用户/密码是什么?我可以指定吗?
错误我得到如下:
致命:[remotehost]:失败! => {“failed”:true,“msg”:“无法获取有关远程文件(/ root / certificates)的信息:权限被拒绝”}
1 回答
如果目标路径为
/root/certificates
,则必须:连接为
root
(不推荐),或使用
become: true
使用权限提升 .您的连接帐户必须配置为能够执行此操作 - 所有这些都是well documented,因此请学习并应用 .
此外,您的播放定义中有一个不必要的
connection: local
,它阻止连接到目标服务器 . 去掉它 .考虑到这一点,也许你应该从Ansible文档的Getting Started章开始 .