Ansible 通过 ssh 同步

问题描述

我正在尝试自动备份到云 (Strato HiDrive)。我将云存储配置为只能通过 rsync 访问(通过 ssh 加密)。

手动执行此操作时,效果很好。

localuser$ rsync -rltDvzu --delete -e ssh . remoteuser@rsync.cloud.com:/users/remoteuser/

我试图将其转换为剧本:

- name: Synchronization of src on the control machine to dest on the remote hosts
  synchronize:
    src: /raid5/Pictures/
    dest: rsync://remoteuser@rsync.cloud.com:/users/remoteuser/
    recursive: yes
    private_key: /etc/ansible/roles/backup_server/files/id_rsa
    set_remote_user: no
    copy_links: no
    times: yes
    checksum: yes
    rsync_opts: -e "ssh"
  • 我尝试打开和关闭 set_remote_user。它要求我输入远程用户的密码。
  • 我尝试通过 set_fact 将 ansible_user 设置为 localuser 或 remoteuser。为远程用户显示密码提示

我尝试像这样使用 rsync_opts,因为我认为 private_key 被忽略了:

 -e "ssh -i /etc/ansible/roles/backup_server/files/id_rsa"

错误信息是:

"msg": "rsync: Failed to exec ssh -i /etc/ansible/roles/backup_server/files/id_rsa: No such file or directory"

感谢您的帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)