【问题标题】:Unable to clone git repository in my local using Ansible无法使用 Ansible 在我的本地克隆 git 存储库
【发布时间】:2017-06-01 09:48:27
【问题描述】:

我正在尝试使用 Ansible 从远程服务器克隆一个 git 存储库。这就是我正在尝试的:

---
# - name: '<some name>'
- hosts: localhost
  #vars: 
   # - destination: /home/atul/Workplace/test-ansible 
   # - http_port: 80
   # - max_clients: 200
- gather_facts: true
- tasks: 
    - git: 
        repo: http://<my git url>/test/test.git
        dest: /home/atul/Workplace/test-ansible
        version: master

我在我的终端里得到了这个。

PLAY [localhost] ******************************************************************************************************************************

TASK [Gathering Facts] ************************************************************************************************************************
ok: [127.0.0.1]
ERROR! the field 'hosts' is required but was not set

我不确定我在哪里做错了。

【问题讨论】:

    标签: git ansible


    【解决方案1】:

    我认为您需要指定主机或拥有包含主机的清单文件。

    尝试运行这个:ansible-playbook &lt;playbook&gt;.yml -i [localhost,]

    【讨论】:

    • 大约 1.5 年前,这可能是一个有效的建议(尽管没有真正回答问题)。
    【解决方案2】:

    您应该将剧本定义为单个字典:

    ---
    - hosts: localhost
      gather_facts: true
      tasks: 
        - git: 
            repo: http://<my git url>/test/test.git
            dest: /home/atul/Workplace/test-ansible
            version: master
    

    在您的情况下,您有三个缺少参数的播放。第一个什么都不做,第二个只包含gather_facts,这就是为什么你会收到hosts字段丢失的错误。

    【讨论】:

      猜你喜欢
      • 2018-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-13
      • 2021-09-01
      • 2017-09-09
      相关资源
      最近更新 更多