2016-11-11 47 views
1

克隆专用到位桶回购我有ansible.cfg无法通过ansible

sudo_flags = -H -S -n 
[ssh_connection] 
ssh_args = -C -o ControlMaster=auto -o ControlPersist=60s -o ForwardAgent=yes 

- name: Fetch code from git repo 
    git: repo={{repo_url}} 
     dest={{ proj_path }} 
     version={{ repo_version }} 
     accept_hostkey=yes 
     force=true 

以下配置请记住,我也有在此之前一个

错误消息是须藤运行同一任务:

Warning: Permanently added the RSA host key for IP address '2401:1d80:1010::150' to the list of known hosts.\r\nPermission denied (publickey).\r\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.", "rc": 128, "stderr": "Warning: Permanently added the RSA host key for IP address '2401:1d80:1010::150' to the list of known hosts.\r\nPermission denied (publickey).\r\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n", "stdout": "", "stdout_lines": []} 
+0

您是否尝试删除您要克隆的主机上的密钥。好像〜/ .ssh/known_hosts和〜/ .ssh/authrozed_keys中有一个错误的键 –

回答

2

该错误消息指出,关键是Ansible使用没有权限从到位桶回购克隆,或者Ansible没有使用的关键应该是使用。从这个消息中没有清楚的迹象表明它遇到了哪些问题,所以你必须挖掘一点才能弄清楚发生了什么。


首先,用ssh -i /path/to/key [email protected]测试密钥的权限。

如果您获得Permission denied (publickey),那么该密钥不与任何用户相关联或作为任何回购的部署密钥添加。将公钥添加到需要它的用户或回购站。

如果你得到这样的事情 -

logged in as some-username-here. 

You can use git or hg to connect to Bitbucket. Shell access is disabled. 
Connection to bitbucket.org closed. 

那么关键就是与该用户的账户相关联。

如果你得到这样的事情 -

authenticated via a deploy key. 

You can use git or hg to connect to Bitbucket. Shell access is disabled. 

This deploy key has read access to the following repositories: 

那么键被添加作为部署(即只读)键,这些回购。


如果密钥的权限是好的,那么ssh-agent没有运行或者它不知道密钥。尝试更新ssh_args到这样的事情:

ssh_args = -C -o ControlMaster=auto -o ControlPersist=60s -o ForwardAgent=yes -i /path/to/key 

这将迫使Ansible使用指定键连接。