Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 通过ansible playbook安装私人宝石时捆绑安装挂起_Ruby On Rails_Ruby_Ansible_Ansible Playbook - Fatal编程技术网

Ruby on rails 通过ansible playbook安装私人宝石时捆绑安装挂起

Ruby on rails 通过ansible playbook安装私人宝石时捆绑安装挂起,ruby-on-rails,ruby,ansible,ansible-playbook,Ruby On Rails,Ruby,Ansible,Ansible Playbook,我试图在使用私有repo中的gem的远程主机上运行bundle install。任务挂起是因为它停止接受主机密钥,因为我无法在本地运行ansible playbook时手动接受远程主机上的密钥 剧本任务 如何通过远程主机上的密钥文件测试或添加github连接 我还通过ssh与github建立测试连接,尝试在bundle安装之前显式接受密钥 - name: test connection to git command: ssh -vvv git@github.co key_file=/

我试图在使用私有repo中的gem的远程主机上运行
bundle install
。任务挂起是因为它停止接受主机密钥,因为我无法在本地运行ansible playbook时手动接受远程主机上的密钥

剧本任务

如何通过远程主机上的密钥文件测试或添加github连接

我还通过ssh与github建立测试连接,尝试在bundle安装之前显式接受密钥

  - name: test connection to git
    command: ssh -vvv git@github.co key_file=/home/ubuntu/.ssh/id_rsa accept_hostkey=yes

现在这个命令也挂起了。

您可以在您的ANSIBLE播放环境中放置
导出ANSIBLE\u HOST\u KEY\u CHECKING=False
。将此添加到您的游戏中,以避免主机密钥检查

environment:
    ANSIBLE_HOST_KEY_CHECKING:  False

另一种可以尝试的方法是将底层的严格密钥检查参数传递给ssh连接。参数为-
StrictHostKeyChecking=no
UserKnownHostsFile=/dev/null
。您可以检查并使用
ansible\u ssh\u common\u args
ansible\u ssh\u extra\u args

根据
@Ankit\u Kukarni
注释,我尝试将
github.com
添加到
已知主机
文件中,最后成功了

将以下代码添加到剧本中


可以找到详细的解释

这是针对
git:
type gem参考的吗?值得注意的是,GitHub私有repo确实可以作为合适的安装源工作,我从来没有遇到过这些问题。@tadman是的,我有
git:
type gem referenceI我尝试过这样做,但不知何故它不起作用。在命令包安装处于运行状态时,我在详细输出中注意到的原因是,主机密钥验证仅在连接到远程服务器时被忽略,而在连接到github以安装带有ssh urlTry的gem时被忽略。请尝试执行此操作
ssh keyscan-H github.com>/.ssh/known_hosts
。这个命令基本上是将github密钥添加到已知主机文件中。一旦你这样做了,它就不会再问你了,直到指纹发生变化
environment:
    ANSIBLE_HOST_KEY_CHECKING:  False
  - name: ensure github.com is a known host
    sudo: yes
    lineinfile:
      dest: /home/ubuntu/.ssh/known_hosts
      create: yes
      state: present
      line: "{{ lookup('pipe', 'ssh-keyscan -t rsa github.com') }}"
      regexp: "^github\\.com"