Ansible Playbook 将文件复制到远程主机 - 权限被拒绝 - 如何发送凭据?
Ansible Playbook to copy a file to a remote host - Permission denied - How to send credentials?
我正在尝试使用简单的 Ansible 剧本将本地文件复制到远程主机:
---
- 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
但是我的权限被拒绝了。尝试将文件发送到远程主机时使用的 User/Password 是什么?我可以指定吗?
我得到的错误如下:
fatal: [remotehost]: FAILED! => {"failed": true, "msg": "Failed to get information on remote file (/root/certificates): Permission denied"}
鉴于目标路径是 /root/certificates
,您必须:
连接为 root
(不推荐),或
使用 become: true
的权限升级。
您的连接帐户必须配置为能够执行此操作 — 所有这些都是 well documented,因此请学习并应用。
此外,您的播放定义中有一个不必要的 connection: local
阻止连接到目标服务器。删除它。
考虑到这一点,也许您应该从 Ansible 文档的 Getting Started 章节开始。
我正在尝试使用简单的 Ansible 剧本将本地文件复制到远程主机:
---
- 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
但是我的权限被拒绝了。尝试将文件发送到远程主机时使用的 User/Password 是什么?我可以指定吗?
我得到的错误如下:
fatal: [remotehost]: FAILED! => {"failed": true, "msg": "Failed to get information on remote file (/root/certificates): Permission denied"}
鉴于目标路径是 /root/certificates
,您必须:
连接为
root
(不推荐),或使用
become: true
的权限升级。您的连接帐户必须配置为能够执行此操作 — 所有这些都是 well documented,因此请学习并应用。
此外,您的播放定义中有一个不必要的 connection: local
阻止连接到目标服务器。删除它。
考虑到这一点,也许您应该从 Ansible 文档的 Getting Started 章节开始。