[英]unable to git clone on local using ansible
我正在嘗試在本地系統上克隆一個git repo。 我已經手動完成了它,但效果很好,但是當我嘗試通過ansible進行操作時,它卻無法解決
這是我的戲:
---
- 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
我得到的錯誤是
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": []}
該目錄在localsystem上為空,我有正確的鍵。 不知道為什么會這樣
您正在多個主機目標上同時運行任務,每個目標都委派給本地主機,從而有效地相互競爭:
fatal: [10.0.3.219 -> localhost]: ... fatal: [10.0.4.36 -> localhost]: ...
將run_once: true
添加到任務。
您有兩個錯誤:
path '/home/nishant/superb-queue' already exists and is not an empty directory
git@bitbucket.org: Permission denied (publickey).
~/.ssh
使用相同的SSH密鑰。 如問題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 }}
在這里, dest
應該是克隆存儲庫的(不存在的)根文件夾(不是~
,而是~/myrepo
)
根據您的問題,我假設您使用的是公共倉庫,那么您應該已經添加了key_file
並且可能還需要添加一個用戶。
請查看以下解決方案以獲取更多信息https://stackoverflow.com/a/39735848/9857025
讓我們知道是否有幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.