我想在本地系统上克隆一个git仓库。我已经手动完成了此操作并且运行良好,但是当我尝试使用Ansible执行时,它无法正常工作。
这是我的playbook:
---
- 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": []}
本地系统上的目录为空,而我拥有正确的密钥。不确定为什么会出现这种情况。