我正在尝试在我的本地系统上克隆一个 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
Run Code Online (Sandbox Code Playgroud)
我得到的错误是
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": []}
Run Code Online (Sandbox Code Playgroud)
localsystem 上的目录是空的,我有正确的键。不知道为什么会这样
你有两个错误:
path '/home/nishant/superb-queue' already exists and is not an empty directorygit@bitbucket.org: Permission denied (publickey).~/.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 }}
Run Code Online (Sandbox Code Playgroud)
这里,dest应该是克隆存储库的(不存在的)根文件夹(不是~,而是~/myrepo)。
您正在多个主机目标上同时运行任务,每个目标都委托给本地主机,有效地相互竞争:
Run Code Online (Sandbox Code Playgroud)fatal: [10.0.3.219 -> localhost]: ... fatal: [10.0.4.36 -> localhost]: ...
添加run_once: true到任务中。
| 归档时间: |
|
| 查看次数: |
7600 次 |
| 最近记录: |