使用ansible将git repo拉到一个流浪盒中

时间:2015-07-21 06:35:13

标签: vagrant ansible ansible-playbook vagrant-provision

大家好我试图通过ansible从我的github把一个回购邮件拉到一个流浪者的盒子里,引用this github issue。我已经使用github在我的主机上注册了一个ssh。以下是我试图拉动的剧本中的一部分;

  - 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后,我已将公钥和私钥复制到该框中,但我的配置在最后一步失败了。我无法提取回购,而是得到以下错误;

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,但那也没有飞行

1 个答案:

答案 0 :(得分:1)

/home/projects/myproject目录中初始化存储库,然后尝试将github存储库克隆到同一目录。

删除初始化任务,从框中删除/home/projects/myproject目录并再次运行您的剧本。