【发布时间】:2015-11-05 07:38:12
【问题描述】:
我正在尝试使用 Ansible 为 ssh 连接创建基础架构。
- name: Copy ssh key to each server
copy: src=static_folder_key dest=/home/ec2-user/.ssh/ mode=0600
- name: Enable ssh Agent
shell: eval $(ssh-agent -s)
- name: Adding ssh key for static forlder project
shell: ssh-add /home/ec2-user/.ssh/static_folder_key
sudo: True
我创建一个新的 ssh 密钥并复制到我的服务器。然后我执行代理,然后添加新密钥以允许连接。但是当我执行 ansible 时,我得到了这个错误。
TASK: [git | Adding ssh key for static forlder project] ***********************
failed: [admin_vehicles] => {"changed": true, "cmd": "ssh-add /home/ec2-user/.ssh/static_folder_key", "delta": "0:00:00.004346", "end": "2015-08-12 15:05:00.878208", "rc": 2, "start": "2015-08-12 15:05:00.873862", "warnings": []}
stderr: Could not open a connection to your authentication agent.
failed: [leads_messages] => {"changed": true, "cmd": "ssh-add /home/ec2-user/.ssh/static_folder_key", "delta": "0:00:00.004508", "end": "2015-08-12 15:05:01.286031", "rc": 2, "start": "2015-08-12 15:05:01.281523", "warnings": []}
stderr: Could not open a connection to your authentication agent.
FATAL: all hosts have already failed -- aborting
如果我手动执行此操作,一切都会好起来的。
ssh-add /home/ec2-user/.ssh/static_folder_key
Identity added: /home/ec2-user/.ssh/static_folder_key (/home/ec2-user/.ssh/static_folder_key)
那么有什么建议吗?也许我在剧本任务中遗漏了一些东西?
【问题讨论】:
-
你试过authorized_key模块吗?authorized_key
标签: ssh ansible ssh-keys ansible-playbook ssh-agent