【问题标题】:Error when pulling from git in ansible - {Failed to find required executable git}在 ansible 中从 git 拉取时出错 - {Failed to find required executable git}
【发布时间】:2017-01-10 18:55:52
【问题描述】:

我正在尝试使用 Ansible 从我的两个 Git 存储库中提取,但我似乎遇到了这个错误:

failed: [app01] (item={u'dest': u'/etc/', u'repo': u'Vigorate'}) =>{"failed": true, "item": {"dest": "/etc/", "repo": "Vigorate"}, "msg": "Failed to find required executable git"}
failed: [app01] (item={u'dest': u'/etc/', u'repo': u'Paint-UI'}) => {"failed": true, "item": {"dest": "/etc/", "repo": "Paint-UI"}, "msg": "Failed to find required executable git"}

我的 git.yml 剧本如下所示:

编辑:

- hosts: app01
vars:
 - destination: /home/vagrant/rep
tasks:

- name: Install dependencies
  apt: name={{ item }} state=present
  with_items:
    - htop
    - git-all

- name: Pull from Git
  git: repo=http://git@github.com/*****/{{ item.repo }}.git
       dest={{ item.dest }}
      # accept_hostkey=yes
      # force=yes
      # recursive=no
  with_items:
    -
      dest: "{{ destination }}"
      repo: RepoEexample
  #  -
   #   dest: "{{ destination }}"
    #  repo: RepoExample

任何帮助将不胜感激

【问题讨论】:

    标签: git github ansible ansible-playbook


    【解决方案1】:

    我相信此错误表明您的 ansible playbook 中的 git: 无法识别且不存在。您要确保在使用 git 之前已安装它。比如:

     - name: Install dependencies
       yum: name={{ item }} state=present
       with_items:
         - htop
         - git-all
         - python-devel
    

    将安装 htop、git 和 python,然后运行 ​​git 节。

    如果您确定 git 已安装,那么下一个可能的错误可能是您的 with_items 部分的语法。尝试将其分解为两个不同的代码节(乏味,是的)只是为了确保它有效,如果有效,它是当前版本的格式而不是 git 问题。

    ---------更新

    确保以下内容有效,然后专注于使用单个代码节克隆多个 repos。

    - name: Pull from Git
      git: repo=git@github.com/daniyalj/Vigorate.git
           dest=/path/to/destination
    

    【讨论】:

    • 好的,解决了!但现在我似乎收到错误“致命:存储库'git@github.com/daniyalj/Vigorate.git'不存在\n”感谢您的帮助@laughing-horse
    • 太棒了!您将要仔细检查那里的 git-URL。确保你有正确的(无论是 http 还是 ssh)。同样,我建议编写不带变量的代码,以确保您在花哨之前已经确定了语法,然后再把它们放回去。
    • 不客气(感谢您的支持!)。 Goodluck 与您的其他 ansible 工作一起工作(我自己刚刚完成了一个月的 ansible 配置 :))
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-13
    • 1970-01-01
    • 2014-01-24
    • 2016-09-07
    • 2016-07-08
    • 1970-01-01
    相关资源
    最近更新 更多