使用ansible将git repo拉到无业游民的盒子 [英] Pulling git repo to a vagrant box using ansible
问题描述
您好,我正在尝试通过ansible将我的github仓库中的存储库拉到一个无所事事的盒子,请参考此github问题.我已经从我的主机向github注册了一个ssh.下面是我要尝试的剧本部分;
Hi all I am trying to pull a repo from my github to a vagrant box via ansible, refering this github issue. I have registered an ssh from my host with the github. And below is the part in the playbook where I'm trying to pull;
- name: install git
apt: name=git
- name: create the ssh public key file
copy: src=/home/user/.ssh/id_rsa.pub dest=/root/.ssh/id_rsa.pub mode=0644
- name: create the ssh private key file
copy: src=/home/user/.ssh/id_rsa dest=/root/.ssh/id_rsa mode=0600
- name: setup git repo
git: repo=git@github.com:myusername/project_foo_bar.git dest=/home/projects/myproject accept_hostkey=yes key_file="/root/.ssh/id_rsa"
在安装git之后,我已经将我的公钥和私钥复制到了盒子中,但是在最后一步中,我的配置失败了.我无法拉回购协议,而是出现以下错误;
After installing git I've copied my public and private keys to the box but my provisioning fails in the last step. I'm unable to pull the repo, instead get the below error;
TASK: [setup git repo] ********************************************************
failed: [default] => {"cmd": "/usr/bin/git ls-remote origin -h refs/heads/master", "failed": true, "rc": 128}
stderr: fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
msg: fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
FATAL: all hosts have already failed -- aborting
我错误地输入了地址.我尝试了repo=ssh://git@github.com/myusername/project_foo_bar.git
,但是也无法飞行
Am I wrongly entering the address. I tried repo=ssh://git@github.com/myusername/project_foo_bar.git
but that too doesn't fly
推荐答案
您在/home/projects/myproject
目录中初始化存储库,然后尝试将github存储库克隆到相同的目录中.
You init a repository in /home/projects/myproject
directory and then try to clone a github repo to the very same directory.
删除初始化任务,从框中删除/home/projects/myproject
目录,然后再次运行您的剧本.
Remove init task, delete /home/projects/myproject
directory from the box and run your playbook again.
这篇关于使用ansible将git repo拉到无业游民的盒子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!