[英]unable to git clone on local using ansible
I am trying to clone a git repo on my localsystem. 我正在尝试在本地系统上克隆一个git repo。 I have done this manually and it works fine, but when i try to do it via ansible, it doesn't work out 我已经手动完成了它,但效果很好,但是当我尝试通过ansible进行操作时,它却无法解决
Here is my play: 这是我的戏:
---
- name: Create a directory on root
file:
path: "{{ local_home_dir }}/superb-queue"
owner: "{{ local_user }}"
group: "{{ local_user }}"
state: directory
delegate_to: localhost
- name: Clone the bitbucket queue repo locally
git:
repo: git@bitbucket.org:superbhq/queue-main.git
dest: "{{ local_home_dir }}/superb-queue"
clone: yes
recursive: yes
force: yes
accept_hostkey: yes
version: master
key_file: "{{ local_home_dir }}/.ssh/id_rsa"
become_user: "{{ local_user }}"
delegate_to: localhost
The error i get is 我得到的错误是
ASK [deploy-queue-main : Clone the bitbucket queue repo locally] ******************************************************************************************************************************************
fatal: [10.0.3.219 -> localhost]: FAILED! => {"changed": false, "cmd": "/usr/bin/git clone --origin origin '' /home/nishant/superb-queue", "msg": "fatal: destination path '/home/nishant/superb-queue' already exists and is not an empty directory.", "rc": 128, "stderr": "fatal: destination path '/home/nishant/superb-queue' already exists and is not an empty directory.\n", "stderr_lines": ["fatal: destination path '/home/nishant/superb-queue' already exists and is not an empty directory."], "stdout": "", "stdout_lines": []}
fatal: [10.0.4.36 -> localhost]: FAILED! => {"changed": false, "cmd": "/usr/bin/git clone --origin origin '' /home/nishant/superb-queue", "msg": "Cloning into '/home/nishant/superb-queue'...\nWarning:********@bitbucket.org: Permission 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": "Cloning into '/home/nishant/superb-queue'...\nWarning: Permanently added 'bitbucket.org,104.192.143.3' (RSA) to the list of known hosts.\r\ngit@bitbucket.org: Permission 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", "stderr_lines": ["Cloning into '/home/nishant/superb-queue'...", "Warning: Permanently added 'bitbucket.org,104.192.143.3' (RSA) to the list of known hosts.", "git@bitbucket.org: Permission denied (publickey).", "fatal: Could not read from remote repository.", "", "Please make sure you have the correct access rights", "and the repository exists."], "stdout": "", "stdout_lines": []}
The directory is empty on the localsystem , and i have the right keys. 该目录在localsystem上为空,我有正确的键。 Not sure why this is happening 不知道为什么会这样
You are running the task concurrently on multiple host targets, each of which is delegating to the local host, effectively competing with each other: 您正在多个主机目标上同时运行任务,每个目标都委派给本地主机,从而有效地相互竞争:
fatal: [10.0.3.219 -> localhost]: ... fatal: [10.0.4.36 -> localhost]: ...
Add run_once: true
to the task. 将run_once: true
添加到任务。
You have two errors: 您有两个错误:
path '/home/nishant/superb-queue' already exists and is not an empty directory
git@bitbucket.org: Permission denied (publickey).
~/.ssh
. 确保使用与您的帐户相同的帐户运行Ansible,以便在~/.ssh
使用相同的SSH密钥。 As mentioned in issue 5722 , try: 如问题5722中所述 ,请尝试:
- name: Clone code repository
git: repo=example.com/repos/enterprise.git
dest=/home/user/enterprise
accept_hostkey=yes
force=yes
recursive=no
key_file={{ userhome }}/.ssh/id_rsa
depth={{ repo_depth }}
Here, dest
should be the (non-existing) root folder of the cloned repository (not ~
, but ~/myrepo
) 在这里, dest
应该是克隆存储库的(不存在的)根文件夹(不是~
,而是~/myrepo
)
From your question, I assume that you are using public repo if not then you should have added key_file
and you probably need to add a user also. 根据您的问题,我假设您使用的是公共仓库,那么您应该已经添加了key_file
并且可能还需要添加一个用户。
Please have a look at the below solution for more info https://stackoverflow.com/a/39735848/9857025 请查看以下解决方案以获取更多信息https://stackoverflow.com/a/39735848/9857025
Let us know if this helped. 让我们知道是否有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.