
2つのリモートサーバーがあり、あるサーバーから別のサーバーにファイルを転送する必要があります。
serverAでsudoユーザーを使用してSSHキー(id_rsa)を生成し、公開鍵をserverB(同じsudoユーザーのauthenticate_keysファイル)にコピーしました。
ホストファイル
[servers]
prod_server ansible_host=IP_prod
new_server ansible_host=IP_new
[servers:vars]
ansible_user=sudo_user
ansible_sudo_pass=sudo_password
ansible_ssh_private_key_file=~/.ssh/sudo_user_key
遊ぶ
- name: Transfer files from prod to new server
hosts: new_server
gather_facts: false
roles:
- rsync
仕事
- name: Copy files to new server
synchronize:
src: /etc/letsencrypt/live/domain/fullchain.pem
dest: /opt
delegate_to: prod_server
プレイブックを実行するとエラーが発生します。
Identity file /home/sudo_user/.ssh/sudo_user_key not accessible: No such file or directory. Permission denied (publickey).
/home/sudo_user/.ssh/id_rsa
タスクはキーではなくキーを見つける必要がありますsudo_user_key
。
この問題にどのように対処する必要がありますか?